[erlang-questions] Orthogonality and Principle of least surprise Was: chained functions

Jeff Schultz jws@REDACTED
Wed Feb 1 14:41:32 CET 2012


On Wed, Feb 01, 2012 at 09:05:10AM +0100, Jakob Praher wrote:
> No matter that the following may be a syntactic surface issue, but
> designating function objects is neither orthogonal nor does follow the
> expectations of the programmer. Therefore it also makes understanding
> code harder.

> if I can write:
>      module:fun().
> I should be also able to write
>      F = module:fun, F().
> and not having to write
>      F = fun module:fun/0, F().

> I am happy to learn why module:fun is not an expression.

If one could write F = module:fun, F(), then presumably one could also
write F = module:fun, F(), F(abc) and call two different functions
thereby.  Nothing particularly wrong with that, though it would mean
that the function actually called would need to be looked up at run
time (rather than just checked for matching arity) and the call would
thus be slower.


    Jeff Schultz



More information about the erlang-questions mailing list