From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id KAA27043 for caml-redistribution; Tue, 14 May 1996 10:06:08 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id VAA19394 for ; Mon, 13 May 1996 21:03:15 +0200 Received: from igw2.watson.ibm.com (igw2.watson.ibm.com [129.34.139.6]) by concorde.inria.fr (8.7.1/8.7.1) with ESMTP id VAA25193 for ; Mon, 13 May 1996 21:03:14 +0200 (MET DST) Received: from lusitania.watson.ibm.com (lusitania.watson.ibm.com [9.2.10.110]) by igw2.watson.ibm.com (8.7.4/8.7.1) with SMTP id PAA11226 for ; Mon, 13 May 1996 15:03:29 -0400 Received: from localhost by lusitania.watson.ibm.com (AIX 3.2/UCB 5.64/4/8/96) id AA18563; Mon, 13 May 1996 15:03:12 -0400 Message-Id: <9605131903.AA18563@lusitania.watson.ibm.com> X-Mailer: exmh version 1.6.2 7/18/95 To: caml-list@pauillac.inria.fr Subject: Re: Class variables in O'Caml Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 13 May 1996 15:03:12 -0400 From: Chet Murthy Sender: weis Jerome Vouillon writes ::On Fri, 10 May 1996, Thorsten Ohl wrote: ::> ::> >>>>> "Christian" == Christian Boos writes: ::> ::> Christian> IMO, the use of references is not so unnatural. Together ::> Christian> with structs, it provides a clean way to encapsulate global ::> Christian> state and actions for classes. ::> ::> Sure, it us possible to do it. But, IMHO, class variables should be ::> declared in the class and be opaque. If you put several classes in a ::> module, the use of module wide references makes much less sense. ::> Another hack is to define a sub-module for each class, but that's not ::> nice either ... ::> ::> I'm just curious if (and why) this syntactic sugar has been left out ::> intentionally. :: ::It has not been left out intentionally. Many object-oriented languages ::(C++, Objective C and Modula 3, for instance) do not have class variables, ::so I did not even thought of adding them. ::But I do not plan to implement class variables. I don't want to add too ::many features, and I don't think they are an important one: in my ::opinion, they are not commonly used, and they can be easily simulated ::using references as you noticed. :: :: Jerome Vouillon Actually, C++ statics are class variables. I would not be surprised if Objective-C had them, too, given that Java has them too. (I haven't looked at ObjC doce in a long time) Class variables are valuable syntactic sugar, because they group the mutable, but shared, state of a class together, in a way which is difficult for a naive programmer to ignore. In the commercial world, it seems that such function, while admittedly syntactic sugar, is important. I guess what I'm saying is, it would be a really nice thing if O'Caml has them -- it would make it much easier to sell to the commercial sector. --chet--