[erlang-questions] Parse-transforming !! to a function call

Jeff Rogers <>
Sat Aug 25 00:34:16 CEST 2007


Mats Cronqvist wrote:
> On 2007-08-16 10:52, Joe Armstrong wrote:
>> [...]
>> (Actually we dont use ? any more so we could say A ? B instead of A !! B
>>  this might be even better - it saves one character and the ? clearly
>>  indicates the intent)
> 
>    if only... but as far as i know '?' is munched by the preprocessor.
> 
>    also, i think that if anything '?' should be used instead of 
> 'receive' (the way God, or at least Tony Hoare, intended).
> 
>    mats

Could a parse transform recognize the case where the value A ! B is not 
discarded and change those cases into some kind of synchronous call?  So 
that

A = spawn(...),
A ! whatever,
ok.

is a async call but

A = spawn(...),
B = A ! whatever,
B.

is a synchronous call.  The return value of ! is normally just the value 
that was sent, which doesn't seem very useful.  The only places where it 
would not be immediately evident if the return value is ignored is when 
a function or Fun evaluates to a send.  Even so, ! normally looks like 
an imperative operator more than a functional one so this seems to make 
it more functional (but also lazy in some respects, which is 
anti-erlang/soft-rt)

-J



More information about the erlang-questions mailing list