is_function vs tuples (functions in non-local modules)

Sean Hinde sean.hinde@REDACTED
Fri Jun 11 14:24:29 CEST 2004


The Fun as tuple syntax is one of the wilder old bits of cruft in 
Erlang. I would just document that it isn't supported by your parser.

I would guess that no-one uses it in new code except to make that point 
that they can..

Sean

On 11 Jun 2004, at 13:02, mats cronqvist wrote:

>> Parser_tr = fun(X)->parser:tr(X) end.
> #Fun<erl_eval.6.39074546>
>> is_function(Parser_tr).
> true
>
>   in your example Fun is a tuple.
>
>> Here's another one that's got me scratching my head:
>>
>> 1> c(parser).
>> {ok,parser}
>> 2> parser:tr("x").
>> "<tr>x</tr>"
>> 3> Fun = {parser, tr}.
>> {parser,tr}
>> 4> Fun("x").
>> "<tr>x</tr>"
>> 5> {parser, tr}("x").
>> "<tr>x</tr>"
>> 6> is_function(Fun).
>> false
>> 7> is_function({parser, tr}).
>> false
>>
>> Is there any way to tell?
>>
>> Reason being, I want to pass a list of things to a function.  This 
>> function should only call the ones that are actually functions.  I 
>> guess I could use catch, but that's got it's own problems (if it is a 
>> function and it errors out, I want the error to be passed on up) and 
>> doesn't seem elegant.
>>
>> Thankyou once again for your time,
>
>




More information about the erlang-questions mailing list