[<<][staapl][>>][..]
Tue Jul 15 12:18:50 CEST 2008

MetaOCaml / MetaScheme

( Edit from: Fri Jun 27 13:02:41 CEST 2008 )

http://okmij.org/ftp/Computation/Generative.html#meta-scheme

4 special forms:

bracket
escape
lift (cross-stage-persistence)
run

  "Scheme's quasiquotation, being a general form for constructing
  arbitrary S-expressions (not necessarily representing any code), is
  oblivious to the binding structure."

But quote-syntax and unsyntax do this correctly, right? Hmm.. I don't
see it without thinking..

EDIT:

  "... uses a complex macro ALPHA that is aware of the binding
  structure. ALPHA traverses its argument, presumed code expression,
  and alpha-converts all manifestly bound variables to be unique
  symbols."

This I can understand: alpha-renaming to make sure names are unique
before splicing in code.

  "Since syntax-rules can only produce globally-unique
  identifiers but not globally-unique symbols, we must use syntax-case
  or a low-level macro-facility.

OK, if the goal is to create code that has a symbolic representation,
this is clear. The syntax-case case uses generate-temporaries for the
unique names.

But does it need to be like that? If we're generating
code that is eventually to be compiled, why not generate a graph
structure directly?

  "The macro ALPHA is implemented as a CEK machine with the
  defunctionalized continuation."

Ok, so it's an interpreter basicly. CEK is the machine underlying
Scheme, as opposed to i.e. SECD for lisp. The CEK is implemented in
syntax-rules.

It might be interesting to see how alpha renaming and cross-stage
persistence are problematic or avoided in Staapl/Coma. Alpha renaming
is avoided by using a point-free target language. CSP is qw. It
supports numbers, target-address dependent expressions which can be
reduced during the assembly stage, and macros which need to be
eliminated during postprocessing.

Ok. Staapl is quite a bit simpler, because I'm doing metaprogramming
and code generation in the same spot. It's only because point-free
code is linear + that all code generators need a finalization step
that this trick works.




[Reply][About]
[<<][staapl][>>][..]