Re: How many arguments to a macro transformer? Andre van Tonder (04 Aug 2005 13:46 UTC)
Re: How many arguments to a macro transformer? Keith Wright (09 Aug 2005 06:23 UTC)
Re: How many arguments to a macro transformer? felix winkelmann (09 Aug 2005 06:49 UTC)
Re: How many arguments to a macro transformer? Andre van Tonder (09 Aug 2005 13:39 UTC)

Re: How many arguments to a macro transformer? Andre van Tonder 09 Aug 2005 13:38 UTC

On Tue, 9 Aug 2005, Keith Wright wrote:

> This revision is more than a trival change.  It seems to me
> that it would be a good idea to extend the discussion period
> to give more time to think about it.

I certainly agree that discussion is not finished and I will request an
extension from the editor.

> MzScheme also has two procedures called |datum->syntax-object|
> and |syntax-object->datum|.  These conflict with your newly
> renamed  |datum->syntax| and |syntax->datum|.  I don't know
> why you changed the names, but it is a conflict, not a
> compatibility, because the MzScheme syntax objects are not
> lists and can not be accessed with |car| and |cdr|.
>
> It seems unlikely that programs written to work with the
> MzScheme system that used these procedures could run unchanged
> on the SRFI system or vice-versa---the data types are completely
> different!

Although, as long as you don't use |car|, |cdr|, etc., and just use
syntax-case with the pattern matching idiom described in the syntax-case
papers, you can ignore the difference.  One may therefore, if one wishes,
regard the fact that syntax objects are lists as an irrelevant implementation
detail, and stick with a purely portable programming style, which the shorter
names datum->syntax would prevent.

I must say that I personally also like the shorter datum->syntax better.
However, with the longer version, /pure/ "portable syntax-case" macros will be
portable between the canonical Chez implementation and the system described
here.  For example, the macros |loop| and |include| on

  http://www.scheme.com/csug/syntax.html#g2138

will work unmodified with this SRFI.  I believe that they will also work
unmodified on MzScheme.

As an aside, the canonical Chez implementation does allow |car| and |cdr| in
some situations.  See, on the above page, the uses of (car cmore) and (cdr
cmore) and also (null? cmore):

(define-syntax cond
   (lambda (x)
     (syntax-case x ()
       ((_ c1 c2 ...)
        (let f ((c1 (syntax c1)) (cmore (syntax (c2 ...))))
          (if (null? cmore)
              (syntax-case c1 (else =>)
                ((else e1 e2 ...) (syntax (begin e1 e2 ...)))
                ((e0) (syntax (let ((t e0)) (if t t))))
                ((e0 => e1) (syntax (let ((t e0)) (if t (e1 t)))))
                ((e0 e1 e2 ...) (syntax (if e0 (begin e1 e2 ...)))))
              (with-syntax ((rest (f (car cmore) (cdr cmore))))
                (syntax-case c1 (=>)
                  ((e0) (syntax (let ((t e0)) (if t t rest))))
                  ((e0 => e1) (syntax (let ((t e0)) (if t (e1 t) rest))))
                  ((e0 e1 e2 ...)
                   (syntax (if e0 (begin e1 e2 ...) rest)))))))))))

(However, Chez does not allow this on all syntax objects, which is confusing.
Also, this macro will not work on MzScheme.)

Cheers
Andre