[plt-scheme] eval-string namespace

From: Paulo Jorge de Oliveira Cantante de Matos (pocm at mega.ist.utl.pt)
Date: Wed Jul 30 09:25:24 EDT 2003

On Wed, 2003-07-30 at 12:06, Robby Findler wrote:
> I think that you have a fundamental misunderstanding about what eval
> does. Without some context of your real problem it is hard to offer any
> suggestions.

Maybe. The situation is as follows. I'm requiring thread.ss and calling
run-server which calls a function like foo that is inside a module like
test. Then it reads from a socket the input of eval-string. On the
socket I want to call bar. When I call bar, an error occurs since it
says it is not able to find it. 

Any ideas?

Best regards,

Paulo

> 
> Robby
> 
> At 30 Jul 2003 12:33:46 +0000, Paulo Jorge de Oliveira Cantante de Matos wrote:
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > 
> > Hi again,
> > 
> > Ok, my situation seems now to be even worse.
> > I've provided all my functions, still I'm not able to call them from
> > toplevel. Check the following simple example:
> > caller.scm:
> > (module caller mzscheme
> >   
> >   (require "test.scm")
> >   
> >   (define (call-it)
> >     (bar))
> >   
> >   (provide call-it))
> > 
> > test.scm:
> > (module test mzscheme
> >   
> >   (require (lib "string.ss"))
> >   
> >   (define (foo)
> >     (eval-string (read-line)))
> >   
> >   (define (bar)
> >     (display "Done"))
> >   
> >   (provide foo bar))
> > 
> > Now I execute caller.scm:
> > > (require "caller.scm")
> > > (call-it)
> > (bar)
> > 
> > . . reference to undefined identifier: bar
> > 
> > 
> > Why can't I call bar if they are on toplevel (since I provided them)?
> > Can't foo and bar be inside a module for me to call them?
> > 
> > Best regards,
> > 
> > Paulo Matos
> > 
> > >From: Robby Findler <robby at cs.uchicago.edu>
> > >To: Paulo Jorge de Oliveira Cantante de Matos <pocm at mega.ist.utl.pt>
> > >Cc: PLT Scheme ML <plt-scheme at list.cs.brown.edu>
> > >Subject: Re: [plt-scheme] eval-string namespace
> > >Date: Tue, 29 Jul 2003 16:24:20 -0500
> > >
> > >When you provide bar, the `require' is putting bar into the toplevel
> > >namespace. Also, when you call eval-string, that code will refer to the
> > >toplevel namespace. If you don't provide bar, then it won't be in the
> > >toplevel namespace, so the eval-string won't find it.
> > >
> > >The point here is that `eval-string' is not lexically sensitive in any
> > >way. It always compiles free identifiers in the input expression to
> > >refer to the toplevel -- not the place where the eval-string was
> > >called.
> > >
> > >Robby
> > >
> > >At 29 Jul 2003 22:15:29 +0000, Paulo Jorge de Oliveira Cantante de
> > >Matos wrote:
> > >>   For list-related administrative tasks:
> > >>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >> 
> > >> Hi all,
> > >> 
> > >> Check the following:
> > >> (module test mzscheme
> > >>   
> > >>   (require (lib "string.ss"))
> > >>   
> > >>   (define (foo)
> > >>     (eval-string (read-line)))
> > >>   
> > >>   (define (bar)
> > >>     (display "Done"))
> > >>   
> > >>   (provide foo))
> > >> 
> > >> If I run this, require test.scm and enter bar for read-line I get
> > that
> > >> bar is undefined. But it'll work alright if I provide bar. Why? 
> > >> I don't understand this behaviour, it's definitely not what I
> > expected.
> > >> In the manual there is no mention to this situation, which is I might
> > >> say strange and boring since I have in the module 20 functions that
> > can
> > >> be called through eval-string that I don't want to provide.
> > >> 
> > >> Any suggestions?
> > >> 
> > >> Best regards,
> > >> 
> > >> Paulo J. Matos
> > >> 
> > >> 
> > 
> > 
> > 
> 



Posted on the users mailing list.