Module attributes

Roger Price <>
Fri Sep 16 16:47:45 CEST 2005


I'm trying to understand the possibilities offered by module
attributes.  My source file "test.erl" contains just the two lines:

-module (test) .
-bad_binary(<<10,20>>) .

I'm using Erlang (BEAM) emulator version 5.4.6 [source] [hipe], and
the compiler crashes as follows:

:~> erlc test.erl
test.erl:none: internal error in core_module;
crash reason:
 {function_clause,[{core_lib,make_literal,[<<10,20>>]},
                   {core_lib,make_literal,1},
                   {v3_core,attribute,1},
                   {v3_core,form,2},
                   {v3_core,module,2},
                   {compile,core_module,1},
                   {compile,'-internal_comp/4-anonymous-1-',2},
                   {compile,fold_comp,3}]}

In the Erlang Reference Manual 5.4.6: Clause 4.2 Module Attributes,
says that a module attribute consists of a tag and a value. -Tag(Term)

Clause 2.1 Terms, says "Erlang provides a number of data types which
are listed in this chapter.  A piece of data of any data type is
called a term."

Clause 2.4 Binary, says that <<10,20>> is a binary and therefore a term.

Clause 2.6 Fun says a fun is a functional object.  I conclude that a fun
is a term, but if I write

   -add_one (fun (X) -> X+1 end) .

I get the error message "test.erl:5: bad attribute".

Shouldn't clause 4.2 say that a Module Attribute is -Tag(BasicTerm)
where BasicTerm is an integer, real number, atom or string?

Roger





More information about the erlang-questions mailing list