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

Re: macros vs. blocks



Trevor Blackwell <tlb@anybots.com> writes:

> John Clements <clements@brinckerhoff.org> writes:
> 
> > Hmm.  If you consider the three largest categories of macros [*] to be
> > 1) those that affect evaluation order (if),
> > 2) those that introduce literal data (quote), and
> > 3) those that introduce bindings (let),
> > I don't see how block notation solves any other than category (1).
> 
> I would refine my macros-are-useless claim a bit: languages that already
> have syntax for things such as assignment, variable declaration, and
> quoted data (Python, Perl, Smalltalk, ...) don't benefit much from
> macros.
> 
> Using macros for #2 is probably a bad idea. I think it's generally
> clearer to include the ' symbol (or whatever your favorite language
> uses) than to have some arguments be magically quoted.
> 
> Using macros for #3 is also usually a bad idea. Having macros like CL
> (do) or (while), which magically introduce a variable with non-obvious
> scoping, is hazardous. I'd rather just have one way of declaring
> control-structure variables, like Smalltalk:

A simple example that does #2 and #3 together is BRL's inputs syntax.

(inputs foo bar baz)

is equivalent to CGI.pm's
foo=param('foo');
bar=param('bar');
baz=param('baz');

Scheme is a language where a variable's name generally doesn't matter at
run time.  However, macros that do #2 and #3 together can change it into
a language where the variable's name does matter, and there are times
where that's convenient.


-- 
<brlewis@[(if (brl-related? message)    ; Bruce R. Lewis
              "users.sourceforge.net"   ; http://brl.codesimply.net/
              "alum.mit.edu")]>