[plt-scheme] On hygiene and trust

From: Joe Marshall (jmarshall at alum.mit.edu)
Date: Thu Jul 9 14:51:56 EDT 2009

I'm having difficulty expressing what I mean.

On Thu, Jul 9, 2009 at 10:47 AM, Eli Barzilay<eli at barzilay.org> wrote:
>
> The bottom line is that a hygienic system needs to store more
> information, so you need to put it somewhere.

I understand.  It is this extra information that makes things harder to
deal with.  It isn't *much* harder, but it is harder.

>> I can't `mapcar' over a syntax object.
>
> Sure you can, use `syntax->list' with `map'.

That's not exactly the same.  Sure, I can call syntax->list and then
call list->syntax afterwards (I assume), but I can't just call mapcar.

>> And when I go in the other direction, I have the symbol `foo' and I
>> wish to create some code that uses it, I have to transform it into a
>> syntax object with the appropriate scope.
>
> (Same as above -- you need to add the extra information.)

But why?  Surely there is a reasonable default.

>> On the other hand, I don't much like syntax-case.  It is much more
>> complicated to use, and I see it used too often.
>>
>> I want something else.  I'm not sure what, though.
>
> This is the same thing that drives me crazy over and over.  There's
> hardly any magic in `syntax-case' -- and in fact, you could just as
> well write macros in a `syntax-case'-based systems without ever using
> it.  For example:
>  http://blog.plt-scheme.org/2009/05/explicit-renaming-macros-implicitly.html

This entry makes my point exactly.  syntax-case is just too low-level.
Sure, defmacro is even *lower* level, but that makes it easier to understand.

Suppose I want a macro that examines one of its arguments to see if it
is a lambda expression.  The ideal thing, of course, is a function that
does just that:

(define-syntax foo
  (lambda (stx)
    (if (lambda-expression? (first-argument stx))
        ....)))

At least defmacro allows this:
(defmacro foo (arg0 &rest args)
  (if (eq? (car arg0) 'lambda)    ;; crude, but effective


Again, I'm not saying that I think defmacro is *better*.


-- 
~jrm


Posted on the users mailing list.