ulambda/build-aux/bootstrap
Mike Gerwitz 1d6756a709
rebirth: Add define-macro
This provides preliminary support for traditional Lisp macros, _not_ Scheme
macros as we know them today; this implementation is easy to implement, and
gives us a great foundation for moving forward.

There are caveats to this simple and naive implementation, documented
ad nauseam.  It's probably worth a read if you're studying Rebirth in any
level of detail for whatever reason.

This is a pretty exciting change---it liberates us from rigid compiler
changes and will allow us to rewrite fnmap into macros almost as-is.  The
change is fairly elegant, all things considered---the amount of code is
minimal; most of the change consists of comments describing it and its
caveats.  This is a defining step in Rebirth, and brings it a step closer to
being an actual Lisp rather than a fragment of one.  (Though I still don't
know if Rebirth Lisp will ever actually be a full Lisp.  Please hold the
arguments about Scheme not being a Lisp or I'll respond very immaturely with
"your mom is not a Lisp", and we'll both be very confused and somewhat
offended by one-another, with a net loss overall.  Oh, wait, you're actually
reading this?)

Anyway, changes:

* build-aux/bootstrap/rebirth.scm: Some rephrasing of toplevel comments,
    and addition of macro comments.
  (_macros): New ECMAScript variable.
  (cdfn-macro, macro-compile-result, list->ast): New procedures.  Little
    full of comments.  Lots of sap.
  (parse-lisp): Fix typo.  Add third argument to `cdfn-proc' (#f).
  (cdfn-proc): Add third argument `id-override'.  Use it in place of token
    value, if set.  Remove semicolon from generated ES function (it was
    unneeded to begin with) so that it can be used in macro ES expressions.
  (macro?): New procedure, conditional based on availability of
    `string->es'.
  (apply-proc-or-macro): New procedure.  Conditionally apply macro during
    compiler runtime or compile output for a procedure application.
  (fnmap)[define-macro]: Apply `cdfn-macro'.  This will try to apply it even
    if the procedure isn't defined yet (e.g. first Rebirth pass), so don't
    call it until then!
    [else]: Use `apply-proc-or-macro'.
2017-12-11 22:43:29 -05:00
..
Bootstrap.js bootstrap: Formalize (both command-line and browser) 2017-11-12 00:29:40 -05:00
birth.scm birth: Support for cond-expand else 2017-12-11 22:24:19 -05:00
libprebirth.js libprebirth: Remove unused `append!' 2017-12-05 00:33:34 -05:00
prebirth.js prebirth,birth,rebirth: Permit newlines in strings 2017-12-05 00:47:26 -05:00
rebirth.scm rebirth: Add define-macro 2017-12-11 22:43:29 -05:00