[
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: | Olivier Andrieu <andrieu@i...> |
| Subject: | Re: [Caml-list] Strange parsing of with-clauses |
Richard Jones [Mon, 29 Nov 2004]:
> Not a big problem, but strange nevertheless:
>
> # exception E of string * string;;
> exception E of string * string
> # let f () = raise (E ("a", "b"));;
> val f : unit -> 'a = <fun>
> # try f (); failwith "Not found" with E (a,b) -> (a,b);;
> - : string * string = ("a", "b")
> # try f (); failwith "Not found" with E t -> t;;
> ---
> The constructor E expects 2 argument(s), but is here applied to 1
> argument(s)
>
> (In my actual code I want to return the thrown tuple to the
> caller).
Ah no, the issue is not with the `with' clause but with the exception
definition. `E of string * string' defines an exception with two
arguments of type string, which has a different representation than an
exception with one argument of type "tuple of strings". The latter
should be defined as `E of (string * string)'. There's the same issue
with variant types (but not the polymorphic ones !).
--
Olivier