or maybe not.
I have searched for a way to generate accessor functions with a program,
but did not understand the implementaion on Pharo but I've stolen
something from Gemstone Smalltalk (if that is not ok, would someone
please be so kind to tell me) and there is a method
compileMissingAccessingMethods
and here it is:
compileMissingAccessingMethods
"Creates accessing and updating methods for all instance variables that do not
already have such methods."
| argName newLine allVarNames varNames sel |
argName := 'newValue'.
allVarNames := self allInstVarNames.
[allVarNames includes: argName] whileTrue: [
argName := 'z' , argName.
].
newLine:= Character lf asString.
varNames := self instVarNames.
varNames do: [ :var |
(self includesSelector: var ) ifFalse: [
self class compile: (var , newLine , newLine ,
' "Return the value of the instance variable ''' , var ,
'''."' , newLine , ' ^' , var , newLine).
].
sel := var, ($: asString).
(self includesSelector: sel) ifFalse: [
self compile: (sel, argName , newLine , newLine ,
' "Modify the value of the instance variable ''' , var ,
'''."' , newLine , ' ' , var , ' := ' , argName , newLine).
]
]
Maybe I was just to stupid to find the according function in Pharo,
however this stuff seems to do what I wanted it do do.
If someone has a better idea or just tell me the function of it in
Pharo, well then please do so.
Regards
Friedrich