1. routine_id() question
- Posted by Hayden McKay <hmck1 at dodo.com.au> Nov 15, 2005
- 445 views
The euphoria doc's state that 'routine_id()' is ideal for creating a case/switch statement, I have to agree but I ran into a slight drawback trying to create the the following switch. Eu does'nt allow me to aquire a routine id for a built-in routine. ie: i tried the following
constant -- mempoke = routine_id("poke") -- built-in eu routine & routine_id("poke2") -- custom user routine & routine_id("poke3") -- custom user routine & routine_id("poke4") -- built-in eu routine -- the built-in routines return -1 when passed to routine_id(). (invalid) -- the idea was to use a switch routine like the following instead of the if...elsif...end if -- statements. -- ie - just an example. procedure pokemem(atom addr, object data, integer bpp) call_proc(mempoke[bpp], {addr, data}) end procedure
maybee routine_id() could be reworked to aquire a handler for a built-in routine in the future. Just some food for thought.
2. Re: routine_id() question
- Posted by Greg Haberek <ghaberek at gmail.com> Nov 15, 2005
- 437 views
> -- the built-in routines return -1 when passed to routine_id(). (invalid) > -- the idea was to use a switch routine like the following instead of the yes, they do that since they're built in. To get around this, wrap the functions as so:
function old_peek( atom mem ) return peek( mem ) end function without warning -- turn of redefined warning function peek( atom mem ) return old_peek( mem ) end function with warning
~Greg