[plt-scheme] Dynamic Procedure Invocation

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Mar 25 22:36:17 EST 2005

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)

Robby

At Fri, 25 Mar 2005 18:59:34 -0800, "Alex Peake" wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> 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).
> 
> (I know about apply and I found strin->symbol and I have played with quasiquotation)
> 
> Alex



Posted on the users mailing list.