Ben Tilly <[email protected]> writes: > On Wed, Apr 17, 2013 at 7:29 AM, Greg London <[email protected]> wrote: >> Why use macros when you can write a function? > > Lisp weenie answer: because the arguments to functions may produce > side effects, while with macros you can control that. Of course the > Lisp answer is inapplicable in other languages because their macros > are less reliable. > > C/C++ answer: because with a macro you can choose whether to try to > call functions that might or might not exist on your platform, and > would make the compiler miserable if it saw it.
I haven't really gone there myself (the words template metaprogramming and SFINAE still make me squirm a bit), but I gather you can do most or all of this using templates these days. It's an improvement I think, if nothing else because you're not calling what you're making a macro with whatever expectations that might give a Lisp programmer. Besides, the support for this (e.g. avoiding the monstrous error messages or the weirdly hackish nature of the techniques) is something they look to improve in newer standards, so maybe someday the code to do it will be more natural to people who don't know templates top to bottom. - Mike _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

