[erlang-bugs] : bug
Fri Nov 30 08:53:57 CET 2007
My first reaction to this was that maybe is_reference/1 is
autoimported, but it would be nice and clear if the
"fun is_reference/1" syntax did not do autoimporting. Easier to know
what you get. You can use "fun erlang:is_reference/1" if so inclined.
Then again: if e.g "fun abs/1" has done autoimporting
for years I can only say "fun is_reference/1" working
the way Joe found out is a (mis)feature.
On Thu, Nov 29, 2007 at 05:03:23PM +0100, Richard Carlsson wrote:
> Bjorn Gustavsson wrote:
> > "Joe Armstrong" <> 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.)
> erlang-bugs mailing list
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-bugs