This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: difference between using eval from the interactive prompt and from a file?


* alex mitchell [2011-11-11 01:59] writes:

> I know that eval is generally discouraged, but I've been looking at using
> it for what (I think) is a valid reason. However, I've immediately run
> into a problem.
>
> I notice that this code:
>
> (define (myproc)
>   (display "myproc\n"))
>
> (if (environment-bound? (interaction-environment) 'myproc)
>     (eval '(myproc))
>     (display "not bound\n"))
>
> gives the result "myproc" if I type the code into the kawa prompt
> interactively, but gives the result "not bound" if I save it in a file,
> say "evaltest.scm", and then run "kawa evaltest.scm". Is there a reason
> why, when running from a file, eval can't see myproc? I'm guessing it has
> something to do with the way the file is compiled, and when top-level
> definitions are evaluated. Anyone have any insight or suggestions?

R7RS section 5.1 Programs:

 Expressions occurring at the top level of a program are
 interpreted imperatively; they are executed in order when
 the program is invoked or loaded, and typically perform
 some kind of initialization.

So I think this is one more case where Kawa is not standard conform.

Helmut


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]