Browse thread
Objects contrib
[
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: | Stefan Monnier <monnier+lists/caml/news/@t...> |
| Subject: | Re: Objects contrib: new URL ... |
>>>>> "Fabrice" == Fabrice Le Fessant <fessant@pa.dec.com> 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 significant. > (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)). Stefan