[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christophe Raffalli <raffalli@c...> |
| Subject: | Re: Suggestions |
> Why don't you use the ``when'' clauses of Caml Light 0.7?
>
> let f x =
> match read x with
> C (x1, x2) when
> (match read x1, read x2 with
> C _,C _ -> true
> | _ -> false) ->
> ...code2...
> | _ -> ...code1...
>;;
This is ok in this example, but the problem is that "when" is not a binder !
So if I want to write
let f x =
match read x with
C (x1, x2) when
(match read x1, read x2 with
C (x3,x4),C (x5,x6) -> true
| _ -> false) ->
...code2...
| _ -> ...code1...
;;
x3,x4,x5,x6 are not bound in ...code2... too bad !
With the "where match" match guard it will work and look nicer !
let f x =
match read x with
C (x1, x2) where
match read x1, read x2 with
C (x3,x4),C (x5,x6) -> ....code2....
| _ -> ...code1...
;;
The "where match" is in fact strictly more general than the when:
pat when exp ->
is equivalent to
pat where match exp with true ->
but the when is weaker because it does not bind any variable.
Christophe Raffalli.