[erlang-questions] guard expression restriction

Richard O'Keefe ok@REDACTED
Fri Dec 3 02:20:16 CET 2010


On 2/12/2010, at 11:44 PM, Hynek Vychodil wrote:

> On Thu, Dec 2, 2010 at 9:37 AM, Kostis Sagonas <kostis@REDACTED> wrote:
>> Richard O'Keefe wrote:
>>> 
>>> ...
>>> There is of course a fairly elementary transformation by means of
>>> which anyone who *really* needs a function call in a guard finds
>>> out that they don't.
>>> 
>>>        f(Arguments) when Expression -> Body;
>>>        <rest of f>
>>> 
>>> =>
>>>        f(Arguments) ->
>>>            case Expression
>>>              of true -> Body
>>>               ; false -> f'(Arguments)
>>>            end;
>>>        f(Vars) -> f'(Vars).
>>> 
>>> where f' is the rest of f with the name changed.
>> 
> 
> Anyway, this rewritten version doesn't behaves like guards

It isn't *MEANT* to.  That's the point, really.
If you are calling user-defined functions you SHOULDN'T be
suppressing exceptions.  (Haskell and Clean don't...)



More information about the erlang-questions mailing list