Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

Take a look at do_exec() in execute.e. There are actually two versions, but the old, routine id based stuff is ifdef'd out by default. It should probably be removed at this point. It was initially ifdef'd out for comparison purposes, and just in case we wanted to restore it. But I think the speed benefits are substantial enough for eu.ex that it's worth keeping.

Ok, my break is over, I've recoded that switch in BEu-style, so to say:

switch op [do] -- 'do' reserved for possible optional cyclic mode 
   case ABORT opABORT() ------ pure switching entry 
   case AND opAND() 
   case AND_BITS opAND_BITS() 
   case APPEND opAPPEND() 
   case ARCTAN opARCTAN() 
  stage ASSIGN --------------- cascadeing entry 
  stage ASSIGN_I opASSIGN() -- cascade ends, switch quits 
   case ASSIGN_OP_SLICE opASSIGN_OP_SLICE() 
   ... 
  stage ELSE 
  stage EXIT 
  stage ENDWHILE 
  stage RETRY opELSE() 
exit -- 2 separate cascade bloks 
  stage ENDFOR_GENERAL 
  stage ENDFOR_UP 
  stage ENDFOR_DOWN 
  stage ENDFOR_INT_UP 
  stage ENDFOR_INT_DOWN 
  stage ENDFOR_INT_DOWN1 opENDFOR_GENERAL() 
   case ENDFOR_INT_UP1 opENDFOR_INT_UP1() 
   ... 
   case TASK_SELF opTASK_SELF() 
 -------------------------- an example of the original code 
   case res:TASK_STATUS: -- undocumented feature ?  
	opTASK_STATUS()  -- 
	 break 
 -------------------------				 
   case TASK_SUSPEND opTASK_SUSPEND() 
   ... 
   case XOR_BITS opXOR_BITS() 
else -- common *else* for cascade and switch modes 
      RTFatal( sprintf("Unknown opcode: %d", op ) ) 
end switch 

It has 212 lines instead of 537 of original version, requires just 2 exit commands, and looks better for reading and understanding, I think. It is 100% compartible with bilingual mode and can be cyclic.
Anyway I'm out of town now, so can not reply.
As far as I can see, 'break' means delay in main process sometimes, so 'exit' is much better for BEu. Let's change 'break' to 'stage' - one key word plus, one key word minus.


kinz

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu