Explanation of macros; Haskell macros

Bruce Lewis brlspam at yahoo.com
Wed Nov 5 18:57:08 CET 2003

stephen at dino.dnsalias.com (Stephen J. Bevan) writes:

> I'm not asking you to give the full requirements for your program,
> only explaining why if it isn't clear what the problem is then nobody
> can easily tell if the macro-based solution is an improvement over
> anything else.

I have to get back to class soon, but here's a quick rundown of two
macros in BRL (http://brl.sourceforge.net/) and why I think they're
nicer than HOFs for the same purpose:

In ASP/VBScript you might do something like


A BRL macro makes it simply:

(define-input a b c)

Half as many opportunities for typos, as you can both use the name of
the variable and bind the variable.

BRL also has a sql-repeat macro.  Within it is some syntax, e.g.
(group-ending? expr)

Here, expr is any expression where the free variables are bound to data
columns returned from an SQL query.  It returns true if you're at the
end of the results, or if expr will be different for the next row.  This
kind of predicate turns eager evaluation on its ear, but lazy evaluation
won't give it to you either.  You can do it with HOFs, but not so
concisely.  As this is a simple, intuitive mental concept, the
conciseness is nice.

That's all for now.  Class is starting.

More information about the Python-list mailing list