<div dir="ltr">But why does eval's default namespace include "+" but not "expt"?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 20, 2014 at 10:39 AM, Éric Tanter <span dir="ltr"><<a href="mailto:etanter@dcc.uchile.cl" target="_blank">etanter@dcc.uchile.cl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is answered in the Racket Guide, see section 15.1.<br>
<br>
The reason is that you need to provide a namespace (which in the interaction mode is already initialized).<br>
<br>
So if you do:<br>
<br>
#lang racket/base<br>
(define ns (make-base-namespace)) ; create namespace<br>
<span class="">(define p1 '(a . (expt 2 3)))<br>
</span>(eval (cdr p1) ns) ; pass it to eval<br>
<br>
it works.<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Éric<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> On Nov 20, 2014, at 12:26 PM, Manfred Lotz <<a href="mailto:manfred.lotz@arcor.de">manfred.lotz@arcor.de</a>> wrote:<br>
><br>
> Hi there,<br>
> If I do this in a REPL<br>
><br>
> Welcome to Racket v6.1.1.<br>
> -> (define p1 '(a . (expt 2 3)))<br>
> -> (eval (cdr p1))<br>
> 8<br>
><br>
> it works fine<br>
><br>
> If I put it in a file:<br>
><br>
> #lang racket/base<br>
> (define p1 '(a . (expt 2 3)))<br>
> (eval (cdr p1))<br>
><br>
> I get this:<br>
><br>
> expt: unbound identifier;<br>
> also, no #%app syntax transformer is bound<br>
> at: expt<br>
> in: (expt 2 3)<br>
> context...:<br>
> /home/manfred/tmp/test.rkt:<br>
> [running body]<br>
><br>
><br>
> What am I doing wrong? Sorry, if this is a stupid question.<br>
><br>
><br>
><br>
> --<br>
> Manfred<br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div>