1. routine_id() question

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.

new topic     » topic index » view message » categorize

2. Re: routine_id() question

> -- 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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu