Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Re: Class variables in O'Caml
@ 1996-05-14 22:50 David Gurr
  1996-05-15 17:48 ` Roberto Di Cosmo
  0 siblings, 1 reply; 3+ messages in thread
From: David Gurr @ 1996-05-14 22:50 UTC (permalink / raw)
  To: chet, caml-list



Chet Murthy <chet@watson.ibm.com>:
> 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.

"mutable, but shared, state of a class" sounds wrong.  How about
"mutable shared state of instances of a class" or "mutable state of 
a class"?  The latter is simply a slot of a class object.  The former
is a limited form of delegation.  What ever would be desired for
the commercial sector, please stick to the pedantic tradition of
ML and give extensions a coherent semantics.  -D





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Class variables in O'Caml
  1996-05-14 22:50 Class variables in O'Caml David Gurr
@ 1996-05-15 17:48 ` Roberto Di Cosmo
  0 siblings, 0 replies; 3+ messages in thread
From: Roberto Di Cosmo @ 1996-05-15 17:48 UTC (permalink / raw)
  To: chet, caml-list


In Objective-C, there is no language support for class variables,
only for class methods...
But since that is a kind of C anyway, you can achieve sort of the
same effect by declaring a static variable in the file containing  
the class
implementation, and access/modify it through class methods (that, again,
are supported) ...

(this is just to complete the C++/Objective-C/Java picture: by the way,
 Java is embarassingly similar to Objective C, and even the online  
documentation
 copies a lot on NeXT's one ... does anybody know for sure if  
Java's designer are really
 former NeXT's employees, as somebody told me?)

As for what Objective Caml should have... I do not have yet a clear  
idea...
It seems to me that some kind of support for "safe" dynamic typing would
be more urgent, maybe...

--Roberto





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Class variables in O'Caml
@ 1996-05-13 19:03 Chet Murthy
  0 siblings, 0 replies; 3+ messages in thread
From: Chet Murthy @ 1996-05-13 19:03 UTC (permalink / raw)
  To: caml-list



Jerome Vouillon writes
::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

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--







^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-05-15 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-14 22:50 Class variables in O'Caml David Gurr
1996-05-15 17:48 ` Roberto Di Cosmo
  -- strict thread matches above, loose matches on Subject: below --
1996-05-13 19:03 Chet Murthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox