From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA23742 for caml-redistribution; Fri, 18 Jun 1999 17:36:14 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA01311 for ; Thu, 17 Jun 1999 20:45:43 +0200 (MET DST) Received: from tequila.cs.yale.edu (TEQUILA.CS.YALE.EDU [128.36.229.152]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA12984 for ; Thu, 17 Jun 1999 20:45:41 +0200 (MET DST) Received: from tequila.cs.yale.edu (localhost [127.0.0.1]) by tequila.cs.yale.edu (8.9.3/8.9.3) with SMTP id OAA15780 for ; Thu, 17 Jun 1999 14:45:40 -0400 To: caml-list@inria.fr Sender: weis From: "Stefan Monnier" Newsgroups: lists.caml Subject: Re: Objects contrib: new URL ... References: <14183.51513.8527.191081@virtualc5.pa.dec.com> <19990617112633P.garrigue@kurims.kyoto-u.ac.jp> <14185.11632.214915.820706@virtualc5.pa.dec.com> Date: 17 Jun 1999 14:44:05 -0400 Message-ID: <5lg13q4qh6.fsf@tequila.cs.yale.edu> X-Newsreader: Gnus v5.7/Emacs 20.3 Path: tequila.cs.yale.edu NNTP-Posting-Host: tequila.cs.yale.edu X-Trace: 17 Jun 1999 14:44:05 -0500, tequila.cs.yale.edu >>>>> "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 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