<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
This conversation has been good. I agree with both Svante<br>
and Scott.<br>
<br>
As is often the case with the spec, it is not quite unambiguous.<br>
It seems to me that the spec is having trouble deciding whether<br>
it is a real, strict, firm language spec, or a useful tutorial/reference<br>
documentation aimed at what programmers care about<br>
the most. Both are worthy things to do but they can be<br>
at odds with each other in some cases. For class slots,<br>
I think some parts of the spec may have been written<br>
without class slots in mind, forcing all of us to be<br>
"language lawyers", infering things from fragments.<br>
<br>
The Java Language Spec is like the first one, and when<br>
it comes to this topic it is utterly specific. (That's<br>
what happens when Guy Steele writes a spec;<br>
yes, I am a GLS fanboy...)<br>
<br>
Shared slots are based on a venerable idea,<br>
from Smalltalk-80. But that language didn't<br>
have any other kind of variable besides<br>
slots of instances!<br>
<br>
If you have class c1 with shared slots cs1 and cs2,<br>
why not just have two global variables (e.f. defvar)<br>
called *cs1* and *cs2* sitting next to the defclass?<br>
<br>
At least one reason, and maybe the only reason,<br>
is that the initial value is figured out in a way<br>
that may depend on class precedence.<br>
<br>
Whether that justifies the added complexity<br>
of having the feature is hard to prove one<br>
way or the other; it's a matter of opinion.<br>
I don't think I've ever used class slots.<br>
<br>
-- Dan<br>
<br>
Martin Simmons wrote:<br>
<blockquote
cite="mid:201101061314.p06DEGhr010244@higson.cam.lispworks.com"
type="cite">
<pre wrap=""><!---->
Overall, I think shared slots are a bad idea. As discussed in a previous
topic, defclass by itself doesn't provide very good encapsulation.
Another gotcha is that reevaluating a defclass with a different value for the
initform doesn't reinitialize the slot.
</pre>
</blockquote>
</body>
</html>