Nice.  Thank you, Asumu.  That helps.

On Wed, Apr 6, 2016 at 5:39 PM, Asumu Takikawa <as...@ccs.neu.edu> wrote:

> Hi David,
>
> On 2016-04-06 17:19:05 -0700, David Storrs wrote:
> >    Macros are one of the biggest features that people list as the
> advantages
> >    of LISP / Scheme, and I don't really understand them.  I get the
> basics --
> >    they can create new code structures -- but not the implications  What
> have
> >    you used them for, and what do they do that a function couldn't?
> What are
> >    good times to use them, and what are their drawbacks?
>
> There are three "canonical" uses of macros that people often talk about.
> The
> main reference for this idea is an e-mail by Matthias on the LL1 list:
>
>
> http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg01539.html
>
> (quoted below)
>
> At Sat, 25 May 2002 11:03:02 -0400 (EDT), Matthias Felleisen wrote:
> >  I'd like to propose that there are three disciplined uses of macros:
> >
> >  1. data sublanguages: I can write simple looking expressions and
> >  create complex nested lists/arrays/tables with quote, unquote etc
> >  neatly dressed up with macros.
> >
> >  2. binding constructs: I can introduce new binding constructs with
> >  macros. That helps me get rid of lambda's and with placing things
> >  closer together that belong together. For example, one of our teachpacks
> >  contains a form
> >    (web-query ([last-name
> >                  (string-append "Hello " first-name " what's your last
> name?"])
> >      ... last-name ... first-name ...)
> >  with the obvious interaction between a program and a Web consumer
> implied.
> >    [Note: In ML you could write
> >       web-query(fn last-name => ...)string_append(...)
> >     but by golly that's a pain and an unnecessary pattern.]
> >
> >
> >  3. evaluation reordering: I can introduce constructs that delay/postpone
> >  the evaluation of expressions as needed. Think of loops, new
> conditionals,
> >  delay/force, etc.
> >    [Note: In Haskell, you don't need that one.]
> >
> >  I understand that Lispers use macros for other reasons. In all honesty,
> I
> >  believe that this is partly due to compiler deficiencies, and partly
> due to
> >  "semantic" irregularities in the target language.
> >
> >  I challenge people to address all three issues when they say language X
> >  can do what macros can do.
>
> I think Modern Racket may have additional uses for macros that don't quite
> fit
> into these. For example, the use of macros that expand into submodules in
> order
> to provide metadata for other programs/tools.
>
> Cheers,
> Asumu
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to