A sender() BIF?

Michael Turner leap@REDACTED
Sun Feb 21 14:20:39 CET 2010

It's conventional for certain purposes to make the first term of a
message tuple be the sender, where the receiver needs to know. 
Recently, I started wondering: why isn't the appropriate sender already
available within each receive scope, via a BIF (or even via some special

I haven't found any BIF like this, so far.  Nor do I see any way to
write it as an Erlang function or macro, though I'm guessing this might
be possible.

Does the idea of sender() violate encapsulation in some meaningful way? 
As matters stand, a module just has to take it on faith that a Pid
identified as sender in a message actually *is* the sender.  So, if
anything, the current arrangement seems to be a source not only of code
verbosity, but (admittedly minor) risk of error as well.

-michael turner

More information about the erlang-questions mailing list