[R6RS] Internal DEFINE vs. macros

Michael Sperber sperber
Mon Apr 25 04:37:18 EDT 2005

dyb at cs.indiana.edu writes:

> The price we pay for powerful language features is that the power can be
> abused to write obscure code.  Internal define-syntax adds to the power,
> so it adds to the risk of obscure code.  Used properly, however, it leads
> to clearer code, just like internal define, syntax-rules, include, etc.

The problem is that you haven't convinced me that internal DEFINE,
INCLUDE, and internal DEFINE-SYNTAX are a great help writing clearer
code.  You seem to regard this as an obvious axiom, but it isn't
obvious to me.  (I'm not convinced of the opposite, either, but I sure
feel uneasy at this point.)  To make the difference clearer:

- I avoid internal DEFINE about the same way I avoid DO.  When I do, I
  often make mistakes because the semantics isn't clear to me.

- I only use an INCLUDE-like facility in highly-controlled
  circumstances equivalent to the FILES form in the Scheme 48 module
  language.  (Which enforces the restriction I abide to.  Which may
  prove your point in this instance or mine, take your pick.)

- I almost invariably find code that is less deeply nested easier to
  read than more deeply nested code.  (And I usually use the module
  system to make my code less deeply nested.)  This also means
  less internal definitions in many circumstances.

For internal DEFINE-SYNTAX, I haven't seen an example yet where it
will make code clearer as compared to code that uses LET-SYNTAX or
LETREC-SYNTAX.  That may be because I haven't seen many examples of
internal DEFINE-SYNTAX yet at all: a cursory grep in the PLT
collection hierarchy revealed none, and the portable syntax-case
implementation also has none.  (For the reasons described in this
thread, DEFINE-SYNTAX occurring at the top level of the body of a
top-level module doesn't count.)  So I'm hoping you'll indulge me and
help me out with a few examples :-)

Cheers =8-} Mike
Friede, V?lkerverst?ndigung und ?berhaupt blabla

More information about the R6RS mailing list