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 GAA29494; Tue, 16 Jul 2002 06:48:07 +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 GAA29575 for ; Tue, 16 Jul 2002 06:48:06 +0200 (MET DST) Received: from dewberry.cc.columbia.edu (dewberry.cc.columbia.edu [128.59.59.68]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6G4m5T05736; Tue, 16 Jul 2002 06:48:05 +0200 (MET DST) Received: from there (tw304h3.cpmc.columbia.edu [156.111.84.180]) by dewberry.cc.columbia.edu (8.9.3/8.9.3) with SMTP id AAA02340; Tue, 16 Jul 2002 00:48:04 -0400 (EDT) Message-Id: <200207160448.AAA02340@dewberry.cc.columbia.edu> Content-Type: text/plain; charset="iso-8859-1" From: Oleg To: Xavier Leroy Subject: Re: [Caml-list] Five Questions about Objects Date: Tue, 16 Jul 2002 00:48:26 -0400 X-Mailer: KMail [version 1.3.2] Cc: caml-list@inria.fr References: <200207131340.JAA07158@hickory.cc.columbia.edu> <20020714174734.E28103@pauillac.inria.fr> In-Reply-To: <20020714174734.E28103@pauillac.inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sunday 14 July 2002 11:47 am, Xavier Leroy wrote: > > 2) What is the point of "class" and "new" keywords? How are they better > > than "let" ? E.g. > >  > > let point a b = > >   object > >     val x = a > >     val y = b > >     method get () = (x, y) > >   end;; > >  > > let my_point = point 3 7;; > > let many_float_points = Array.make 100 (point 4.0 3.0);; > > ? > > The main purpose of the class system is to support inheritance and > method overriding.  Object-oriented programming comes in two flavors: > class-based OOP, which is what all mainstream OO languages offer, and > delegation-based OOP, where there are no classes, objects are built > directly by listing their fields and methods like you suggested, and > method overriding is performed directly on objects, e.g. via a "copy > this object, replacing these methods" operation.  While there have > been some theoretical work on delegation-based OOP, I think it is fair > to say that it is less well understood than class-based OOP. I thought my suggestion had to do with syntax only. One could still write things like type color = Red | Green | Blue let pixel a b (c:color) = object inherit point a b as p val col = c method get_color () = col method get_coords () = p#get () end I don't really see any significant "OO flavor" difference, just simpler and more consistent syntax IMHO: two keywords are eliminated, and class definition is now just function definition. If that is not the case, can you give examples in current O'Caml syntax that do not translate well into this "syntax" ? Thanks Oleg ------------------- 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