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 LAA28152; Mon, 14 Jun 2004 11:29:03 +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 LAA25154 for ; Mon, 14 Jun 2004 11:29:02 +0200 (MET DST) Received: from postfix4-1.free.fr (postfix4-1.free.fr [213.228.0.62]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i5E9T1EV016986 for ; Mon, 14 Jun 2004 11:29:02 +0200 Received: from [192.168.2.8] (auteuil-1-81-57-2-20.fbx.proxad.net [81.57.2.20]) by postfix4-1.free.fr (Postfix) with ESMTP id 51AE310DF71 for ; Mon, 14 Jun 2004 11:29:01 +0200 (CEST) Subject: Re: [Caml-list] troubles with polymorphic variant in class From: =?ISO-8859-1?Q?Fran=E7ois-Xavier?= HOUARD Reply-To: IdeFX@Iname.com To: caml-list@inria.fr In-Reply-To: <1087149590.16811.1342.camel@pelican.wigram> References: <1087142756.10383.50.camel@Bess> <1087149590.16811.1342.camel@pelican.wigram> Content-Type: text/plain; charset=ISO-8859-15 Message-Id: <1087205340.8886.4.camel@Bess> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 14 Jun 2004 11:29:01 +0200 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 40CD6FDD.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 iname:99 2004:99 fixpoint:01 widget:01 widget:01 unwieldy:01 uglier:01 struct:01 gui:01 extensible:01 coca-ml:01 ecrit:01 polymorphic:01 equation:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le dim 13/06/2004 à 19:59, skaller a écrit : > (* fixpoint *) > type widget = 'w widget' as 'w > > which effectively solves the type equation > 'w = 'w widget (and names the result widget). > Now define non-polymorphic classes: > > class button = [widget] button' > class window = [widget] window' > > This is not so bad for a single parameter 'w. > For multiple parameters the notation soon becomes > too unwieldy to be practical. But the answer you gave me, which I find quite nice, don't allow my user to add his own class.... I could do the stuff with a parametrized module (the parameter given by the user would contain the variant used in the program... Including the ones of my library!!), or, even uglier, use a close variant in my module, which would be like: [ Window of window | Frame of frame | User_variant of 'a ] And 'a, the parameter of the module, given by the user, would also be a variant... module SillyModule = struct type t = [ MyWindow of myWindow | MyText of myText ];; end ;; module myGui = Gui (SillyModule);; let a = new Window;; let x = new myText a;; let l = a#get_child in match l with h::t -> (match h with myGui.User_variant v -> ( match v with MyText t -> ....... | _ -> ) | _ -> raise Not_found ) .... Who the hell would use this ??? So, if I can't find a better solution, i could still try to find a sado-m(l)asochist mailing list, to find potential users ! ;)) Let's be more serious. What you said is fine, but, please, tell me there is an easier solution to make it work with user defined class... Please.... Thanks for all FX Houard, desperate to find an elegant and extensible solution to his problem... And attracted by the dark-dynamic-typed side of coca-ml. ------------------- 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