Fun syntax

Vlad Dumitrescu <>
Tue Jul 30 21:48:50 CEST 2002


Hi,

you are right, Erik: by "remote" I meant "from another module".

> > I am a little confused about the syntax for functional objects when the
> > referred function is remote. The way to define a fun is then
> >     Fun = {lists, reverse}
>
>No, it is not. Don't tell anyone that this works ;)

Well, it's stated in the docs about the Fun syntax:

    We can also refer to a function defined in a different module
    with the following syntax:
        F = {Module, FunctionName}
    In this case, the function must be exported from the module
    in question.


>I think the reason is that the entity lists:reverse/1 does not exist at 
>compile time, the address of the function can only be found at load time or 
>at the time of the call.

I was thinking that internally 'lists:reverse' could be represented just as 
'{lists, reverse}' - the new syntax could only be clearer and more 
consistent.

> > What I find even strange is that it works to write something like
> >     {lists, reverse}([1,2,3]).
>Yes, this is terrible and ugly in so many ways... and it is going to go 
>away.

Good!

>In some generic servers you want to store dynamic callback functions.

Yes, but as you say, that's why apply is here for.

best regards,
Vlad

_________________________________________________________________
Med MSN Foto kan du enkelt dela med dig av dina fotografier och beställa 
kopior: http://photos.msn.se




More information about the erlang-questions mailing list