"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Tuesday, January 27, 2009

Do you practice hygiene (with your macros)?

No. God no.

Hygienic macro systems are a sign of weakness and a false crutch. If you can't write a macro that doesn't inadvertently capture a variable, you shouldn't be writing programs that write programs.

(Been a while since I've ranted. Hasn't it?)

2 comments:

Pichi said...

Principally with closures you don't have to use macros at all. This is theoretical assumption. I found, that most of macros I used to use I can write as functions and for performance I can force in-line it. (When used in .hrl -compile({nowarn_unused_function, [...]}).) Macros I'm using only in guards and some very rare cases (fun()-> end is too much verbose for some usage or subtle expansions), but most of this can be solved by parse transformations. In conclusion I found macros are still useful for some subtle performance reasons but I'm using it less often. Impossibility to use own function in guards force macros where I would not like to see one.

Anonymous said...

Pichi, I agree that you usually want to avoid macros in Erlang. The ugliness of the question-mark prefix just emphasizes this.

But in Scheme/Lisp there is a long tradition of sugaring the syntax, and there is no cultural prejudice against defining macros. Provided, of course, that your macros don't suck, and that you don't over-do it.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.