Email list hosting service & mailing list manager

Potential change in sample implementation - comments? David A. Wheeler (29 Jul 2013 16:27 UTC)

Potential change in sample implementation - comments? David A. Wheeler 29 Jul 2013 16:27 UTC

I'm thinking about adding and using a macro in the
to simplify the Scheme reference implementation.
Any comments?

Currently, the sample implementation includes
many lines that look like this:
; Run (n-expr-first port) and put results in various variables
(let* ((basic-full-results (n-expr-first port))
       (basic-special      (car basic-full-results))
       (basic-value        (cadr basic-full-results)))
  ...)

I'm thinking about using an R5RS-style macro
so all such lines would instead look like:
(let-splitter (basic-full-results basic-special basic-value)
  (n-expr-first port)
  ...)

The macro definition would look like this:
; I'm intentionally requiring exactly 3 variables for now, since
; that's all that's used.  It could be modified later to be more flexible.
(define-syntax let-splitter
  (syntax-rules ()
    ((let-splitter (full first-value second-value) expr body ...)
      (let* ((full expr)
             (first-value (car full))
             (second-value (cadr full)))
             body ... ))))

Guile 1.8 doesn't enable R5RS macros by default, but they can be enabled with:
  (use-syntax (ice-9 syncase))
It appears that the same is true for guile 1.6:
  http://www.gnu.org/software/guile/docs/docs-1.6/guile-ref/Syntax-Rules.html#Syntax%20Rules
I believe most other Schemes in wide use have R5RS macros.
Even old/partial Schemes that did NOT support R5RS macros
should be easily adaptable (it doesn't particularly require a hygenic macro system).
I'd probably do the same with the Common Lisp implementation
(that's outside this group's scope, but I thought I'd mention it).

Comments?  Good idea? Bad idea?

--- David A. Wheeler