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

Re: LFM



Paul Graham writes:
> 
> What they don't mention is how *hard* it would be to add macros
> to a language with static typing, even if they wanted to.

What's so hard about it? The main difficulty I see is maintaining a
phase separation between compile-time and run-time constructs, but you
can easily avoid dealing with that problem if you go with something
like Scheme's syntax-rules macros.

The reason I haven't yet added macros to Needle is completely
different: I want macro authors to be able to specialize the expansion
based on the type of the macro expression. This will permit people to
write macros that can automatically optimize certain special cases
(eg, you can have a foreach loop that will use the general iteration
protocol by default, but will generate a simple integer counter if it
is sure that it's iterating over an array). Basically, static types
mean there's extra information about the program at compile time, and
it makes sense to give the programmer a way of messing with it.

I'm just not sure how to do this yet. :)

-- 
Neel Krishnaswami
neelk@alum.mit.edu