[plt-scheme] Switching to Scheme

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jul 3 02:46:56 EDT 2006

On Jul  2, Mark Engelberg wrote:
> Excellent.  That will be another useful tool for porting Python
> code.  I use generators all the time.

As a side-comment -- this is something that my `collect' macro does
that srfi-42 didn't do.  (At least IIRC...)

  => (define (generate-ints yield)
       (let loop ([n 0])
         (yield n)
         (loop (add1 n))))
  => (list-of x (i <- 1 .. 10
                 and x <- generate-ints))
  (0 1 2 3 4 5 6 7 8 9)

Note that the comprehension has two simultaneous states, the first is
only used to stop the second which is infinite.

> (I suspect that Scheme has some even better constructs for
> developing lazy data structures.

Look for `delay' and `force'.

> I'm already aware of the built-in stream primitives.  Are there some
> other useful ways of creating laziness?).

There is a Lazy Scheme language level that is part of my course
plugin.  This gives you a way to write an application with some
modules written in normal (strict) Scheme, and some in a lazy Scheme.
If you want to play with it -- install


After you restart DrScheme you can use the new "Lazy Scheme" language
level to play with code lazily.  To write code in a lazy module:

  (module foo (lib "lazy.ss" "CSU660")
    ...lazy code...)


* It can be confusing to use this language -- it is *really* a lazy
  language, which can often be surprising

* Code in a plain module (one that uses `mzscheme' as a base language)
  can use code that is provided from lazy modules etc.

* It should still be considered an experimental language.

* For the privacy-aware crowd: getting this plugin will make DrScheme
  check for updates to the plugin whenever it starts, in a way that
  does not disturb work in any way.  This is because I often update it
  during a semester with new languages for homeworks etc.  It is
  irrelevant until the semester starts, and when it does popup a
  message, the check can be disabled.  (Re the discussion from some
  time ago: this is an unrelated feature intended for class use, I
  don't even have access to the logs in this case...)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.