From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA20860; Wed, 22 Oct 2003 03:14:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 DAA15132 for ; Wed, 22 Oct 2003 03:14:46 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9M1Ei127333 for ; Wed, 22 Oct 2003 03:14:44 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id KAA18380; Wed, 22 Oct 2003 10:14:27 +0900 (JST) To: rich@annexia.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] OCaml wishlist In-Reply-To: <20031021223456.GA12195@redhat.com> References: <20031021223456.GA12195@redhat.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20031022101438T.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 22 Oct 2003 10:14:38 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 wishlist:01 jacques:01 inference:01 'just:01 upcast:01 superclass:01 superclass:01 mli:01 constrain:01 jacques:01 ocaml:01 ocaml:01 labelled:01 surprising:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Richard Jones > Thanks for your answer David. In response to the above, I'd say that > I've found OCaml objects to generally be OK, but sometimes they can be > really infuriating! Examples: > > * Type inference doesn't work sometimes, so you need to add 'just the > right' type declaration to an expression to get it to compile. Yes, that's most unfortunate. There are two such difficulties with classes * use of polymorphic or labelled methods (you need to know the type of the objects) * escaping type variables in class definitions For the first one, there is little to be done: whenever you call such a method, you must make sure the type of the object is known. For the second one, there is maybe some room for improvement. > * Upcasting - sometimes it works, sometimes it requires an explicit > :> to upcast. Once or twice I've had a really strange error where > I've needed to do some sort of double upcast-and-type-declaration, > IIRC it was (obj :> superclass : superclass) It should be (obj : current :> superclass). This is the only "guaranteed" cast. Otherwise, you are trying your luck. Still, simple cast should work for all non-recursive classes. > * Polymorphic methods have a really odd & unintuitive syntax. Sorry. My idea was that they would only be used in very special cases, particularly considering the typing problem described above. > * It seems like you need to use a separate MLI file to be able to > define completely private (as opposed to just protected) methods, > which isn't really documented well. Not quite: you can also define a class type by hand and constrain your definition with it. class c : ct = object ... end This may be surprising when coming from Java, but this is more coherent with the rest of the language. Overall, I would not characterize ocaml objects as weak, but rather nonintuitive. Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners