principle of least surprise

Robert Virding <>
Wed Nov 23 00:41:06 CET 2005

That would be quite some flag seeing the level of nesting that 
deep-guards would allow. What about try/catch? Exit and throw? I can 
assure it wouldn't be long before get a discussion about "safe" 
side-effect BIFs. Of course it is perfectly reasonable to allow 
sending/receiving messages in guards, I need to question other processes!

Another problem would be the intransparency of user defined functions. 
While it would easy to understand simple functions written by yourself 
using functions taken from libraries written by other people could lead 
to some very surprising results.


Alex Arnon wrote:

> Could it be possible to trace the execution of such a function 
> executing in a guard, and raise an exception if it performs a 
> side-effect-causing operation? AFAIK the set of such operations is 
> rather small in erlang: (off the top of my head)
> - Message sends.
> - Side-effect inducing BIFs (which can be marked as part of their 
> implementation).
> So if we keep a "side-effect allowed" flag stack along (or as part of) 
> the process stack, implementation should be easy... or would it? :)
> I find this feature to be highly desirable, even more than the 
> multi-scheduler VM that will surely grace us with its presence Real 
> Soon Now. :)

More information about the erlang-questions mailing list