Wed Jun 18 17:22:49 CEST 2008

code transformations

The multi-pass optimization algorithm has an ad-hoc form: the first
pass instantiates macros, while subsequent passes perform specific
substitutions only. I can't express it properly, but shouldn't code
originally have the form ([qw <macro1>] [qw <macro2>] ...) with a
'run' application?

An important question: is there a way to get rid of this 2-pass
mechanism? Is it necessary or just more elegant to use a demand driven

To implement  [ f map g map ] -> [ [ f g ] map ] we need to represent
'map' as a pseudo op:

  (([map f] [qw g] map) ([map (macro: f g)]))
  (([qw f] map)         ([map f]))

And the map can be eliminated in a 2nd pass by instantiating it:

  (([map f] map-pass) (macro: f do-map))

This is entirely too trivial, so all the beef is hidden in the
instantiation of 'map'. Which makes me think, what is 'map'? An
implementation of a data structure iterator + a specification of its
abstract properties used for source manipulation.

next: Think about 'fold' over arbitrary data structures and related
things like loops, iterators, comprehensions, compile time folding,

There's some rewriting in Cat that does this