[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] Re: [RFC] Smalltalk scripting syntax
From: |
Paolo Bonzini |
Subject: |
[Help-smalltalk] Re: [RFC] Smalltalk scripting syntax |
Date: |
Thu, 15 Mar 2007 09:17:11 +0100 |
User-agent: |
Thunderbird 1.5.0.10 (Macintosh/20070221) |
> I don't mind if you don't quote me in full, but chopping paragraphs in
> half is bound to lead to confusion.
Sorry, that was because I was already lost after the first part.
The original full paragraph was:
> I thought you might say that, but there's really no reason why you
> should insist on defining class instance variables in the class method
> scope. It's a nested scope, and Smalltalk has no inner classes, so
> there's no reason to treat it the same as the outer scope.
And now I see what you probably meant. Did you mean
"defining class instance variables" instead of *class variables*
"in the class method scope"?
If so, there is a good reason, and it is that class variables
are misused 99% of the time. Class variables are *global* variables
visible to a hierarchy and, as such, they should be used as little as
possible. When implementing a singleton, for example, what you *really*
want is a uniqueInstance class-instance variable.
The name of class variables is all wrong. I would call them "class pool
variables", or "class global variables", and I would say that "class-instance
variables" are the "real" class variables.
Class variables should be used mostly to include constant objects
(as was the case for pool dictionaries before they became a more general
"import namespace" mechanism), so, it makes sense to me to use a syntax
like this to define them:
Class name: Character extends: Object [
| value |
...
Cr := Character value: 13.
Lf := Character value: 10.
Table := Character initializeConversionTable
]
This is similar to how you would write these initializations in a
Character class>>#initialize method.
In addition, it's not necessary that the class scope be a nested scope
(if this bothers you, please tell me). You can perfectly well write:
Class ref: Character class [
del [ ^Character value: 127 ]
]
(I hope that, with "ref:" as the keyword, it is clearer that the correct
precedence is "Class ref: (Character class)" and not "(Class ref: Character)
class". If you wish to suggest an alternate keyword, again, please do).
Paolo
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, (continued)
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, parasti, 2007/03/14
- [Help-smalltalk] Re: [RFC] Smalltalk scripting syntax, Paolo Bonzini, 2007/03/15
- [Help-smalltalk] Re: [RFC] Smalltalk scripting syntax, parasti, 2007/03/16
- [Help-smalltalk] Directions for GNU Smalltalk (was Re: [RFC] Smalltalk scripting syntax), Paolo Bonzini, 2007/03/16
- [Help-smalltalk] Re: Directions for GNU Smalltalk (was Re: [RFC] Smalltalk scripting syntax), parasti, 2007/03/17
- Re: [Help-smalltalk] Re: Directions for GNU Smalltalk (was Re: [RFC] Smalltalk scripting syntax), Paolo Bonzini, 2007/03/18
- Re: [Help-smalltalk] Re: Directions for GNU Smalltalk (was Re: [RFC] Smalltalk scripting syntax), parasti, 2007/03/18
- Re: [Help-smalltalk] Re: Directions for GNU Smalltalk (was Re: [RFC] Smalltalk scripting syntax), Paolo Bonzini, 2007/03/19
- Re: [Help-smalltalk] Re: Directions for GNU Smalltalk (was Re: [RFC] Smalltalk scripting syntax), parasti, 2007/03/19
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, Mike Anderson, 2007/03/14
- [Help-smalltalk] Re: [RFC] Smalltalk scripting syntax,
Paolo Bonzini <=
- Re: [Help-smalltalk] Re: [RFC] Smalltalk scripting syntax, Mike Anderson, 2007/03/15
- Re: [Help-smalltalk] Re: [RFC] Smalltalk scripting syntax, Paolo Bonzini, 2007/03/15
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, Mike Anderson, 2007/03/12
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, Paolo Bonzini, 2007/03/13
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, David Given, 2007/03/13
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, Paolo Bonzini, 2007/03/14
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, David Given, 2007/03/14
- Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, Paolo Bonzini, 2007/03/14
Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax, Paul D. Fernhout, 2007/03/09