On 15/01/2008, <b class="gmail_sendername">Benjamin Tolputt</b> <<a href="mailto:bjt@pmp.com.au">bjt@pmp.com.au</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Robert Virding wrote:<br>> On 15/01/2008, *Ahmed Ali* <<a href="mailto:ahmed.nawras@gmail.com">ahmed.nawras@gmail.com</a><br>> <mailto:<a href="mailto:ahmed.nawras@gmail.com">ahmed.nawras@gmail.com</a>>> wrote:
<br>><br>><br>> Does (redefining) mean I cannot define a macro with the same name<br>> even though they have different arity?<br>><br>><br>> That is exactly what it means. It was a mistake to do it that way. But
<br>> it could be corrected now if people really want it.<br>I would be interested in a quick pros & cons of this. As I understand it<br>C/C++ has the same "uniquely named" macro functionality.<br><br>As I see it, having macros with arity (
i.e. LOG/1 and LOG/2) would be<br>the Erlang equivalent of declaring a function as "inline". What<br>advantages would this have given I technically could have the equivalent<br>of LOG1 & LOG2 macros?<br><br>
Nto arguing one way or the other, but Robert mentioned it as a mistake<br>and I'm curious as to the reasons for and against such a "mistake".<br></blockquote><div><br>Easy, when macros were first requested all that was asked for was a way for defining constants. I wasn't too convinced of the benefit of adding them at all so as an added "bonus" (it was a joke) I went the "whole hog" and did a copy of C macros. Almost a complete copy anyway. That's why they don't support same name different arity.
<br><br>It wouldn't really be a problem to add that feature now I don't think it would actually break any code. Except perhaps just to not catch errors. Though I doubt it has high priority.<br><br>The reason why they work at token level is that this was easier to do and better provided the functionality that was asked for,
i.e. constants. You can do much cooler things with LISP-like macros but they are "not trivial" to implement in a language which doesn't have a close connection between code and data like LISP or Prolog. Just ask those who have tried for Erlang. Or tried to make a backquote like functionality.
<br><br>Robert<br><br></div></div>