Version française
Home     About     Download     Resources     Contact us    
Browse thread
Class variables in O'Caml???
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jerome Vouillon <vouillon@c...>
Subject: Re: Class variables in O'Caml??? + questions

On Fri, 10 May 1996, Thorsten Ohl wrote:
> 
> >>>>> "Christian" == Christian Boos <boos@gr6.u-strasbg.fr> 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