[erlang-questions] simplified attribute declaration

Vlad Dumitrescu vladdu55@REDACTED
Fri Mar 19 14:18:48 CET 2010


On Fri, Mar 19, 2010 at 13:23, Kostis Sagonas <kostis@REDACTED> wrote:
> What is really happening is that attributes which take just one argument do
> not need to be enclosed in parentheses. On the other hand, attributes with
> more than one argument (read: whenever there is a ',' involved, as in the
> case of -define above) need to be enclosed in parentheses.

Why?

I tried it properly with the following module

-module test.
-export [test/1].
-import lists, [reverse/1].
-record x, {a=3}.

test(X) ->
	{#x{a=4}, reverse(X)}.

and it works just fine to compile and run it, giving the correct result.

The only other attributes that accept two arguments are -module whith
parameters, -file and -define. The first works too and the other two
don't because they are both handled by epp (which has the parentheses
hardcoded in its scanner/parser). I don't see why -file shouldn't work
too and in the case of -define the only problem I can see is in the
case of macro definitions that aren't well-formed expressions.

best regards,
Vlad


More information about the erlang-questions mailing list