[PRL] scope of top-level defines

Paul A. Steckler steck at stecksoft.com
Mon Apr 4 23:01:54 EDT 2005


> > If you try to load the following code into GHCi, the
> > interactive Haskell interpreter:
> > 
> >   x = y
> >   y = x
> 
> What does it do if you just enter the first one?

Although I don't have GHCi installed here, I'm sure 
it would tell you that y is not in scope.

A simpler example that would load fine is 

  x = x

> Here:
> 
> | mzscheme -t lazy.ss
> | Welcome to MzScheme version 209, Copyright (c) 2004 PLT Scheme, Inc.
> | > (define x (cons 1 y))
> | > (define y (cons 2 x))
> | > (take 10 x)
> | (1 2 1 2 1 2 1 2 1 2)

Now see if you can do (pun intended) monadic IO!

-- Paul




More information about the PRL mailing list