[erlang-bugs] bug
Richard Carlsson
richardc@REDACTED
Thu Nov 29 17:03:23 CET 2007
Bjorn Gustavsson wrote:
> "Joe Armstrong" <erlang@REDACTED> writes:
>> start() ->
>> lists:filter(fun is_reference/1, [1,2,3]).
>>
>> %% this program compiles correctly
>> %% it should fail with a missing function
>
> Maybe. I am not sure whether this is a bug or a feature.
> ...the guard BIF is_reference/1 will be called, so the code
> will actually work.
If this is ok:
start() ->
lists:filter(fun (X) -> is_reference(X) end, [1,2,3]).
i.e., if is_reference/1 is in scope, being automatically imported
from the module 'erlang' (just like is_atom/1 and the rest), then
your example should also be perfectly legal and well defined.
(The old-style names reference/1, atom/1, etc., are however not
in scope outside guards, so 'fun reference/1' should cause complaints
about a missing function, unless you have defined it yourself.)
/Richard
More information about the erlang-bugs
mailing list