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

Re: macros vs. blocks

On Friday, November 22, 2002, at 02:11  PM, Christopher Barber wrote:

>> 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.
> Well, the Curl language has syntax for those things, and yet we still 
> find
> the ability to extend the syntax using macros quite useful.  I 
> personally
> use them most frequently in automated tests to construct concise test 
> cases
> that would otherwise require a lot of cutting and pasting or tedious 
> code
> generation.
>>>  (define-syntax assert
>>>    (syntax-rules ()
>>>      ((assert test)
>>>       (if (not test) (assert-error (quote test))))))
>> The assert family is certainly a classic macro application, although
>> having it print something like
>>    ASSERTION FAILURE: (> x 0).
>> is pretty darn useless, since there might be lots of occurrences of
>> (assert (> x 0)) in the code, and also that assertion failures often
>> indicate an error in the caller rather than where the assert statement
>> is. I'd much rather rely on the stack traceback with line numbers and
>> function arguments that any good interpreted language gives you. So I
>> claim this sort of pun is pretty useless.
> That is a quality of implementation issue.  There is no reason that a 
> macro
> system cannot allow you to write macros that refer to the source file 
> and
> line where the macro is expanded.

Indeed.  cf. PLT scheme.

john clements