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 JAA05685; Sun, 20 Oct 2002 09:28:28 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA01905 for ; Sun, 20 Oct 2002 09:28:28 +0200 (MET DST) Received: from morgon.inria.fr (morgon.inria.fr [128.93.8.33]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9K7SO526158; Sun, 20 Oct 2002 09:28:24 +0200 (MET DST) Received: (from remy@localhost) by morgon.inria.fr (8.11.6/8.11.6) id g9JKmNf17602; Sat, 19 Oct 2002 22:48:23 +0200 Date: Sat, 19 Oct 2002 22:48:23 +0200 From: Didier Remy To: james woodyatt Cc: The Trade Subject: Re: [Caml-list] functional objects Message-ID: <20021019224823.A17599@morgon.inria.fr> Reply-To: Didier.Remy@inria.fr References: <5BF65502-E2FD-11D6-B29D-000393BA7EBA@wetware.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <5BF65502-E2FD-11D6-B29D-000393BA7EBA@wetware.com>; from jhw@wetware.com on Fri, Oct 18, 2002 at 05:54:45PM -0700 Organization: INRIA, BP 105, F-78153 Le Chesnay Cedex Phone: (33) 1 3963 5317 -- Sec: (33) 1 3963 5207 -- Fax: (33) 1 3963 5193 Web: http://cristal.inria.fr/~remy Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Anyway, one of the things I find lacking is a way to call a subclass > constructor in the copy constructor. In other words, I'd like to have > some way to do the following: > > (* class type with only public methods exposed *) > class type foo = object method f: unit end > > (* class with private members *) > class foo x : foo = object > val x: int = x > method f = () > end > > (* derived functional subclass (notice method g) *) > class bar y = object > inherit foo 0 > val y: int = y > method g a b = {< foo a; y = b >} > end > > What I want is for a superclass class to be able to expose an interface > to subclasses for constructing copies with arguments. Is this a bad > idea? Has it already been considered and rejected? Just curious. Would the following code makes you happy? (* class type with only public methods exposed, plus a private overriding method foo *) class type foo_ = object ('a) method f : unit method private foo : int -> 'a end;; (* class with private members *) class foo x : foo_ = object val x: int = x private method foo a = {< x = a >} method f = () end;; (* derived functional subclass (notice method g) *) class bar y = object inherit foo 0 val y: int = y method g a b = {< y = b >} # foo a end;; Didier Rémy ------------------- 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