Nested Guards
Ronny Wichers Schreur
ronny at cs.ru.nl
Mon Jul 3 08:29:32 EDT 2006
Bas van Dijk writes (to the haskell-prime list):
> The Clean Report[1] is not really clear on that but to my knowledge
> nested
> guards do not have fall-through semantics.
>
> The report does mention this:
>
> "To ensure that at least one of the alternatives of a nested guard
> will be
> successful, a nested guarded alternative must always have a
> 'default case' as
> last alternative."
I don't think this explanation is accurate. The reason that a nested
guard must
have a default case is syntactical, otherwise there could be the
dangling-else
ambiguity. If I remember correctly, the compiler can handle nested-
guards with
fall-throughs just fine.
There have been proposals to use the offside rule to resolve the
ambiguity, but
I can't recall if this was implemented.
See <http://mailman.science.ru.nl/pipermail/clean-list/
1997/000175.html> for
some examples.
Cheers,
Ronny Wichers Schreur
More information about the Haskell-prime
mailing list