guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is exposing illegal syntax via syntax-rules "normal usage"?


From: Rob Browning
Subject: Is exposing illegal syntax via syntax-rules "normal usage"?
Date: 27 Apr 2001 12:23:53 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

After finally learning (more or less) syntax-rules and looking at how
others and used it to implement non-trivial things, I've seen a lot of
bogus patterns used to implement internal "loops" etc. in the
re-writing rules.  Of course, as far as I can tell, this also makes
certain illegal syntax constructs perfectly legal as far as the
interpreter is concerned which seems, umm, ugly/unfortunate.

What I'm talking about here are things like the following silly
implementation of reverse-it:

  (define-syntax reverse-it
    (syntax-rules ()

      ((reverse-it "not-legal" () result)
        result)

      ((reverse-it "not-legal" (var-1 var-2 ...) result)
       (reverse-it "not-legal" (var-2 ...) (var-1 result)))

      ((reverse-it vars)
        (reverse-it "not-legal" vars ()))))
        
Note that this example is kind of bogus because you don't really need
the "not-legal" cases to implement this macro, but it does demonstrate
my concern, and as far as I can tell, there's no viable alternative if
you want to stick with R5RS macros.

As a practical example of this usage, there are the sample
implementations of srfi-5 and srfi-11.

  http://srfi.schemers.org/srfi-5/srfi-5.html
  http://srfi.schemers.org/srfi-11/srfi-11.html

Thanks

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

[Prev in Thread] Current Thread [Next in Thread]