1. Calling a routine by name

Hi Rob,

Is there a way to call a routine by name using a string?

Example:

procedure exec_mov( atom dest, atom src) ... end procedure
sequence x
x = "exec_mov"
call_proc_byname(x, {0, 1})

This would be a neat way to call procedures, like in an
interpreter application. Instead of using routine_id()
(which is subject to change), we could use the actual
routine name instead, and make it more flexible. That would
eliminate endless if..then..else structures, and allow
things like routine lookup tables and such.

Btw, in Perl you can call a subroutine like this:

sub exec_mov { ... }
$x = 'exec_mov';
&$x;   # calls exec_mov()

Cool, huh?


----->Buddy
budmeister1 at juno.com

new topic     » topic index » view message » categorize

2. Re: Calling a routine by name

Use this to call a procedure by name:

global procedure my_routine (integer arg1, integer arg2, integer arg3)
   .. code ..
end procedure

-- And then you can call it like this:
 call_proc (routine_id ("my_routine"), { arg1, arg2, arg3 } )

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

3. Re: Calling a routine by name

Thanks Ralf :)

I knew there must have been a way to do it,
but I wasn't sure how.


----->Buddy
budmeister1 at juno.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu