[racket] How to make eval work on define?
Does this help:
> #lang racket
>
> (define-namespace-anchor top)
>
> (parameterize ((current-namespace (namespace-anchor->namespace top)))
> (eval '(define x 10))
> (namespace-variable-value 'x))
eval takes a namespace and you need to supply it explicitly (as an argument) or implicitly (via a parameter setting).
On Nov 17, 2012, at 1:06 AM, Monica Tomson wrote:
> Hi,
>
> When I use eval on an S-Expression, where there are something like (define len (...)), racket screams at me define: not allowed in an expression context in: (define len (make-length 10))
>
> My questions are:
>
> How to make eval work on definition?
> If eval is not designed to work on definitions, then is there some workarounds that can make it work?
> I appreciate any help!
>
> Thanks,
>
> Monica
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121117/8aee1061/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121117/8aee1061/attachment.p7s>