• Re: implementing scheme - implementing macros

    From Kragen Javier Sitaker@kragen@canonical.org to comp.lang.lisp on Sat Aug 29 17:15:19 2026
    From Newsgroup: comp.lang.lisp

    Kaz Kylheku <046-301-5902@kylheku.com> writes:
    On 2026-06-12, Mario Rosell <mario@mariorosell.es> wrote:
    I am trying implement macros, and don't really know how to implement them. >> Scheme has a pretty complex macro system, so for now I am trying to
    implement defmacro and then implement define-syntax, syntax-case, etc.

    There exists more than one algorithm for hygienic macros. (...)
    Kohlbecker's algorithm (1986) (...) William Clinger's 1990 paper,
    "Macros That Work"

    This can be one of the hairiest parts of implementing Scheme, but there
    are off-the-shelf free-software library implementations of ClingerrCOs algorithm that you can rCLjustrCY drop into your Scheme if you want.
    They're several thousand lines of code, and yourCOll likely have to
    macroexpand them first on an existing Scheme. The other respondents who
    think theyrCOre just quasiquotation plus eval, similar to Common Lisp
    macros, are being far too optimistic; they will be in for a big surprise
    if they ever try to implement Scheme macros themselves.

    Kragen
    --- Synchronet 3.22a-Linux NewsLink 1.2