[racket] eval question

From: Benjamin Greenman (blg59 at cornell.edu)
Date: Thu Nov 20 10:41:20 EST 2014

But why does eval's default namespace include "+" but not "expt"?

On Thu, Nov 20, 2014 at 10:39 AM, Éric Tanter <etanter at dcc.uchile.cl> wrote:

> This is answered in the Racket Guide, see section 15.1.
>
> The reason is that you need to provide a namespace (which in the
> interaction mode is already initialized).
>
> So if you do:
>
> #lang racket/base
> (define ns (make-base-namespace)) ; create namespace
> (define p1 '(a . (expt 2 3)))
> (eval (cdr p1) ns) ; pass it to eval
>
> it works.
>
> -- Éric
>
>
> > On Nov 20, 2014, at 12:26 PM, Manfred Lotz <manfred.lotz at arcor.de>
> wrote:
> >
> > Hi there,
> > If I do this in a REPL
> >
> > Welcome to Racket v6.1.1.
> > -> (define p1 '(a . (expt 2 3)))
> > -> (eval (cdr p1))
> > 8
> >
> > it works fine
> >
> > If I put it in a file:
> >
> > #lang racket/base
> > (define p1 '(a . (expt 2 3)))
> > (eval (cdr p1))
> >
> > I get this:
> >
> > expt: unbound identifier;
> > also, no #%app syntax transformer is bound
> >  at: expt
> >  in: (expt 2 3)
> >  context...:
> >   /home/manfred/tmp/test.rkt:
> > [running body]
> >
> >
> > What am I doing wrong? Sorry, if this is a stupid question.
> >
> >
> >
> > --
> > Manfred
> >
> >
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
> >
>
>
> ____________________
>   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/20141120/565d08fa/attachment.html>

Posted on the users mailing list.