[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
more things lost....
- To: <tribble>
- Subject: more things lost....
- From: Ravi Pandya <ravi>
- Date: Thu, 26 Apr 90 16:39:21 PDT
- Cc: <xtech>
- In-reply-to: <Eric>,42 PDT <9004262238.AA02807@xanadu>
I don't know whether 'Smalltalk at: #XAxis put: XOrientation create' would ever
have translated correctly, though I doubt it. Anyhow, you should now
use a class variable as follows:
Gnat subclass: Gnu
instanceVariableNames: ''
classVariableNames: 'XAxis {XOrientation}'
poolDictionaries: ''
category: 'Zoo'
Gnat class methodsFor: 'smalltalk initialization'
"the protocol should have keywords smalltalk & init"
linkTimeNonInherited
XAxis _ NULL
initTimeNonInherited
self REQUIRES: XOrientation.
XAxis _ XOrientation create
This makes XAxis a static variable in C++. If other classes need to
access it, you should write functions (class messages) to do it.
--ravi
P.S. If you just need something that is a compile time constant use:
linkTimeNonInherited
Heaper constant: #ONE type: '{IntegerVar}' value: 1
which translates to
const IntegerVar ONE = 1;
P.P.S. From what I can see of this example, it looks like you should
instead be using a pseudo constructor that caches a single instance:
XOrientation ...
classVariableNames: 'TheXOrientation {XOrientation}'
...
XOrientation class methodsFor: 'smalltalk initialization'
linkTimeNonInherited
TheXOrientation _ NULL
initTimeNonInheried
TheXOrientation _ XOrientation create
XOrientation methodsFor: 'pseudo constructors'
make
^TheXOrientation
Then you use XOrientation make where you would have used the variable
XAxis. Inlining makes this just as efficient.