Proposed change to libraries

Bjorn Gustavsson <>
Tue Feb 8 11:54:15 CET 2005


Kostis Sagonas <> writes:
[...]
> However, apparently I am missing the obvious, because I do not see
> how this is easier (though I see that it is more elegant) to
> implement than what we were essentially discussing yesterday...

It is essentially the same, just packaged in a much more elegant way.

> The key question is: does "is_applicable({M,F}, 1)" always check that
> the M:F/1 is a valid fun (and succeeds accordingly) or not?
> 

No. is_applicable/2 cannot still check whether M:F/A will be possible to
apply or not. is_applicable/2 would have to assume that any tuple containing
two atom elements is a valid tuple fun.

But as I see two advantages using is_applicable/2:

1) When/if we'll finally be able to eliminate tuple funs, we can change 
   is_applicable/2 to no longer accept tuple funs (as opposed to changing
   Erlang code in many places).

2) When Dialyzer sees is_applicable/2, it is a stronger type indication
   than just 'foo({M,F}) when is_atom(M), is_atom(F)' which need not be
   a tuple fun. At least it should be enough indication for Dialyzer to
   assume that F has the same type in both clauses of lists:map/2. That
   should allow Dialyzer to generate more warnings than it can today.

If it would be of help to Dialyzer, we might be able to add is_applicable/2
even to R10B-4 (and start using it in library modules such as lists).

On the other hand, I can give no definite time plan for when we'll
be able to forbid tuple funs. Sorry.

/Björn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list