[plt-scheme] Dynamic Procedure Invocation
> From: karczma at info.unicaen.fr
> To: plt-scheme at list.cs.brown.edu
> Subject: Re: [plt-scheme] Dynamic Procedure Invocation
> Date: Sat, 26 Mar 2005 10:13:59 +0100
>
> Robby Findler answers the query:
>
> > "Alex Peake" wrote:
> >> In Common Lisp I can say:
> >>
> >> (funcall (find-symbol "+") 1 2 3)
> >>
> >> -- the key is the proc name is a suitable string (maybe
> read out of a
> >> database) --
> >>
> >> Is there something similar in PLT Scheme (that does not use eval).
>
>
>
> > Without using eval (or procedures beginning with
> namespace-, that are
> > essentially eval): no, not in general.
> >
> > You could make a table of the procedures that you expected
> to see tho:
> >
> > (define table (list (list "+" +) (list "-" -) (list "*"
> *))) (define
> > (call sym . args)
> > (let ([proc (assoc sym table)])
> > (unless proc
> > (error 'call "unknown function ~e" sym))
> > (apply (cadr proc) args)))
> >
> > (call "+" 1 2 3)
>
> = = = = = = = = = = =
>
> But, essentially, is it really different from the search
> through the current environment, say,:
>
> (define a (string->symbol "+"))
> (define b (namespace-variable-value a))
> (apply b '(12 34 56))
>
> Of course, having a private associative namespace may be much
> more efficient in searching time, but the namespace handling
> is (I hope...) quite well optimized.
>
> Anyway, this is quite probably what is done in Common Lisp, no?
>
> So, why this requirement <<no eval>>?
>
> Jerzy Karczmarczuk
>
The <<no eval>> is just a performance issue
Alex