Next: , Previous: , Up: loops generators   [Index] Loop generators

Generator Syntax: :do (?lb ...) ?ne1? (?ls ...)
Generator Syntax: :do (let (?ob ...) ?oc ...) (?lb ...) ?ne1? (let (?ib ...) ?ic ...) ?ne2? (?ls ...)

Defines a generator in terms of a named let, optionally decorated with inner and outer let. This generator is for defining other generators. (In fact, the reference implementation transforms any other generator into an instance of fully decorated :do.)

The generator is a compromise between expressive power (more flexible loops) and fixed structure (necessary for merging and modifying generators).

In the fully decorated form, the following syntactic variables are present:


Outer binding.


Outer command.


Loop binding.


Not end predicate.


Inner binding.


Inner command.


Not end predicate.


Loop step.

They define the following loop skeleton:

(let (?ob ...)
  ?oc ...
  (let loop (?lb ...)
    (when ?ne1?
      (let (?ib ...)
        ?ic ...
        (when ?ne2?
          (loop ?ls ...))))))

where ?oc and ?ic are syntactically equivalent to forms in the body of a begin, i.e. they do not begin with a ?definition. The latter requirement allows the code generator to produce more efficient code for special cases by removing empty let expressions altogether.