[erlang-questions] illegal guard expression: filelib:is_dir(H)

Michael Turner leap@REDACTED
Mon Feb 15 14:36:13 CET 2010


>The reference to Guantanamo is, um, hyperbolic, to put it mildly.

I plead guilty to Argument by Reference to Wikipedia.

(A mitigating circumstance: I was once told by a friend that he'd heard
Dijkstra say, haughtily, at a conference in Asilomar, "'Run a
program'?!  Why, I haven't *run* a program in years!"  Well of course
not.  How silly.  Why run programs when you can be proving them correct
instead?)

-michael turner

On 2/15/2010, "Richard O'Keefe" <ok@REDACTED> wrote:

>
>On Feb 15, 2010, at 1:07 AM, Michael Turner wrote:
>
>>
>> Could be worse, y'know.  At least Erlang "if" guards are checked in
>> the order written.  Dijkstra introduced the term "guard" using if ...
>> syntax as well, but if more than one guard was true, one of the
>> guarded
>> statements was selected "non-deterministically" -- at least if you
>> believe Wikipedia.
>>
>>   http://en.wikipedia.org/wiki/Guarded_Command_Language
>>
>> On the whole, I'd prefer the guards at Guantanamo.
>
>Dijkstra's guarded command language goes with a semantics and
>a >>design method<< in which you write non-overlapping guards
>unless you have >>demonstrated<< that in case of overlap it
>really does not matter which statement you pick.
>
>The classic example is
>	if X <= Y -> Max := Y
>	[] Y <= X -> Max := X
>	fi
>where
>(a) if X = Y then it really does not matter which assignment you choose
>(b) conventional practice introduces an entirely artificial
>     asymmetry between the two cases
>(c) in more complicated cases, it is easier to reason about each
>     choice because, amongst other things, the condition under which
>     this choice is _explicit_, it's not "this and not that and not
>     the other and not some other thing".
>
>Like Erlang's 'if' and 'case', the execution of guards in Dijkstra's
>notation is not allowed to have side effects.  So you can't tell
>what order the guards were tested in except in cases where you've
>demonstrated that you don't care.
>
>The reference to Guantanamo is, um, hyperbolic, to put it mildly.
>
>


More information about the erlang-questions mailing list