[Openmcl-devel] eval-in-package
Ron Garret
ron at awun.net
Sun May 31 08:50:24 PDT 2009
You'll want to read this:
http://www.nhplace.com/kent/PS/Ambitious.html
rg
On May 31, 2009, at 3:15 AM, Taoufik Dachraoui wrote:
> Dear,
>
> I would like to write a function that evaluates a body in a given
> package
>
> Example:
>
>>> ccl
>> (make-package 'test)
>> (in-package 'test)
>> (defun f(n) (if (< n 2) 1 (* n (f (1- n)))))
>> (in-package 'common-lis-user)
>> (format t "factorial of ~d is ~d~%" 5 (eval-in-package (find-package
> 'test) (f 5)))
> => factorial of 5 is 120
>
>
> I tried the follwoing but it does not work (eval uses null-lexical-
> bindings ?)
>
>> (defmacro eval-in-package (p f) `(let ((*package* ,p)) ,f))
>> (eval-in-package (find-package 'test) (f 5))
>
> The purpose of the eval-in-package is to evaluate functions
> dynamically generated and must be evaluated in a given package.
>
> Thank you in advance for your help
>
> Kind regards
> Taoufik Dachraoui
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
More information about the Openmcl-devel
mailing list