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

Re: macros vs. blocks

   Date: 18 Nov 2002 14:34:05 -0000
   From: Paul Graham <pg@archub.org>
   Cc: tlb@umbrellaresearch.com

   If anyone has good examples of macros that *can't* be 
   expressed with a convenient notation for closures, it would
   be interesting to see them.  My Smalltalk-hacking friend
   Trevor Blackwell has often claimed that macros were
   unnecessary if you had blocks, so as long as we're on 
   the subject, please send him (and ll1-discuss) your 

   (The point is not mainly to quiet Trevor, of course, but
   to understand macros better.)

   Thanks!  --pg

You've gotten several good answers to this already.  But here's a nice
simple example that I use in my code every day:

  (define-syntax assert
    (syntax-rules ()
      ((assert test)
       (if (not test) (assert-error (quote test))))))

Where `assert-error' is a utility procedure that formats up a suitable
error message.  I don't see how blocks (or lightweight lambda syntax) can
help you here.