Re: Objects contrib: new URL ...

From: Stefan Monnier (monnier+lists/caml/news/
Date: Thu Jun 17 1999 - 20:44:05 MET DST

From: "Stefan Monnier" <monnier+lists/caml/news/>
Subject: Re: Objects contrib: new URL ...
Date: 17 Jun 1999 14:44:05 -0400

>>>>> "Fabrice" == Fabrice Le Fessant <> writes:
> At the end of this message, you will find a patch to apply on
> patch.cast to raise a Oo.CastFailure exception with the information
> on the file and the line number where the exception was raised.

I have to agree with Jacques: using a match construct (i.e. `typecase')
rather than a `cast' is cleaner. It makes it a lot more obvious that the
cast might fail and in the case where you want to deal with several
alternatives, a `typecase' is exactly what you want, whereas using `cast'
would be very awkward (using handlers all over the place).
Of course a `cast' is a little better in the case where you *know* that
it will succeed, but the textual overhead of a `typecase' does not seem

> (should the compiler allow "x.(-1)" in a program as it currently does?),

No it shouldn't. And type-systems are being developed that catch those uses
(pushing array bounds checking either to compile-time or (when the analysis is
not powerful enough) to the programmer (to insert the checks by hand)).


This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET