[plt-scheme] Problems with eval

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu Jul 3 14:34:04 EDT 2008

This is not a bug.

The top-level namespace (ie the part of the namespace that deals with
code outside modules) for the module language does not have any
bindings. You have to initialize it with some if you want to use them.

It would be better to avoid eval (as has been mentioned a few times on
this list) but on the assumption that eval is truely necessary, try
this:

  #lang scheme
  (namespace-require 'scheme/base)
  (eval '((lambda (x) x) 1))

Without the second line, the third one won't work, but with it, it does.

Robby

On Thu, Jul 3, 2008 at 1:19 PM, Chongkai Zhu <czhu at cs.utah.edu> wrote:
> Yes, you are right. I can reproduce the error. Must be a bug.
>
> Chongkai
>
> Doug Williams wrote:
>>
>> I added the require to the module and it didn't have any affect.  I got
>> exactly the same error.
>>
>> On Thu, Jul 3, 2008 at 12:05 PM, Chongkai Zhu <czhu at cs.utah.edu
>> <mailto:czhu at cs.utah.edu>> wrote:
>>
>>    (require (for-syntax scheme/base))
>>
>>    ?
>>
>>
>>    Doug Williams wrote:
>>
>>        I am converting the inference collection over to run on V4.0.1
>>        and I'm having a problem with dynamically evaluating a lambda
>>        expression.  Here is a snippet of the code that gives the error:
>>
>>        #lang scheme/base
>>        ...
>>        (define (activate-rule rule initial-node)
>>        ...
>>                         (if (null? match-constraints) ;
>>        match-constraint-predicate
>>                             #f
>>                             (eval
>>                              `(lambda ,(if assertion-variable
>>                                            (cons assertion-variable
>>                                                  (pattern-variables
>>        pattern))
>>                                            (pattern-variables pattern))
>>                                 (and , at match-constraints))))
>>        ...
>>         )
>>
>>        And, the error I get is:
>>
>>        compile: bad syntax; function application is not allowed,
>>        because no #%app syntax transformer is bound in: (lambda
>>        (?size ?peg) (and (not (eq? ?peg (quote right)))))
>>
>>        This code works in V372.
>>
>>        Any ideas?
>>
>>        Doug
>>
>>  ------------------------------------------------------------------------
>>
>>        _________________________________________________
>>         For list-related administrative tasks:
>>         http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>>
>>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.