• Re: implementing scheme - implementing macros

    From steve g@Sgonedes1977@gmail.com to comp.lang.lisp on Fri Jun 19 23:15:13 2026
    From Newsgroup: comp.lang.lisp

    Paul Rubin <no.email@nospam.invalid> writes:

    steve g <Sgonedes1977@gmail.com> writes:
    you need to ``reevaluate'' the macro twice.
    the commmon lisp was uses symbols like @ , . etc..

    That's been built into Emacs Lisp for quite a while too. Before it was
    built into the reader, it was available as a loadable macro package so
    you'd write something like (` (setq (, var) (1+ (, var))) . Now it's
    like CL, `(setq ,var (1+ ,var)) .


    yes, I do remeber this. very compilcated to read; much better now.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Kaz Kylheku@046-301-5902@kylheku.com to comp.lang.lisp on Tue Jun 23 20:59:00 2026
    From Newsgroup: comp.lang.lisp

    On 2026-06-12, Mario Rosell <mario@mariorosell.es> wrote:
    [ Repost from Reddit. r/lisp: https://t.ly/Fldzk ]

    Hello everyone.

    I am making a Scheme R5RS implementation and it is going pretty well.

    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.

    Any tips?

    There exists more than one algorithm for hygienic macros.

    The "grand daddy" is Kohlbecker's algorithm (1986)

    The offshoots:

    - Syntactic closures (1988)
    - Alan Bawden paper from the proceedings of the 1988 ACM conference on Lisp
    and functional programming.
    - Chris Hanson 1991 paper, "A Syntactic Closure Macro Facility".

    - Modified Kohlbecker's algorithm:
    - William Clinger's 1990 paper, "Macros That Work"
    - claims to address issues with syntactic closures
    - reduces Kohlbecker from quadratic to linear time
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Stefan Monnier@monnier@iro.umontreal.ca to comp.lang.lisp on Thu Jun 25 10:59:18 2026
    From Newsgroup: comp.lang.lisp

    There exists more than one algorithm for hygienic macros.

    The "grand daddy" is Kohlbecker's algorithm (1986)

    The offshoots:

    - Syntactic closures (1988)
    - Alan Bawden paper from the proceedings of the 1988 ACM conference on Lisp
    and functional programming.
    - Chris Hanson 1991 paper, "A Syntactic Closure Macro Facility".

    - Modified Kohlbecker's algorithm:
    - William Clinger's 1990 paper, "Macros That Work"
    - claims to address issues with syntactic closures
    - reduces Kohlbecker from quadratic to linear time

    Might be worth mentioning the "sets of scopes" one used in Racket:

    Binding as sets of scopes
    Matthew Flatt. POPL 2016.
    doi: 10.1145/2837614.2837620


    === Stefan
    --- Synchronet 3.22a-Linux NewsLink 1.2