valid name for an instance variable?
is x: (with colon) a valid inst var name ? I can create the following object Object subclass: #InstVarNameTest instanceVariableNames: 'x:' classVariableNames: '' category: 'TTT' But of course, I can not write an assignment statement. I am asking because if Symbol>>#asMutator is called an a symbol with colon like x: it returns x:: It looks like that x:: is not even a valid message selector. I would like to change the asMutator method to return x: if it is called on x: (or throw an error ?) nicolai
On 09 Mar 2015, at 13:54, Nicolai Hess <nicolaihess@web.de> wrote:
is x: (with colon) a valid inst var name ?
no.
I can create the following object
Object subclass: #InstVarNameTest instanceVariableNames: 'x:' classVariableNames: '' category: 'TTT'
But of course, I can not write an assignment statement.
Yes, but it is good that it allows to do these things⦠e.g. you can load a class definition with Slots in Pharo3, and it will put the slot definition as the name. If it would raise an error, loading would be impossible.
I am asking because if Symbol>>#asMutator is called an a symbol with colon like x: it returns x::
It looks like that x:: is not even a valid message selector. I would like to change the asMutator method to return x: if it is called on x:
Yes, that would make sense. Marcus
Marcus Denker-4 wrote
is x: (with colon) a valid inst var name ? no.
Why complicate the system by special-handling illegal variable names? Just let the incorrect x: become the just-as-incorrect x::, no? Or am I missing something? ----- Cheers, Sean -- View this message in context: http://forum.world.st/valid-name-for-an-instance-variable-tp4810632p4810780.... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-03-09 22:09 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>:
Marcus Denker-4 wrote
is x: (with colon) a valid inst var name ? no.
Why complicate the system by special-handling illegal variable names? Just let the incorrect x: become the just-as-incorrect x::, no? Or am I missing something?
No it is not about handling illegal variable names. The question is, what should #name: asMutator return 1. #name: because it is already a mutator 2. #name:: because it might be the mutator for variable "name:" (2) is how it actually behaves, but because "name:" is not a valid instance variable name, returning #name:: does not makes sense, so I choose option (1). nicolai
----- Cheers, Sean -- View this message in context: http://forum.world.st/valid-name-for-an-instance-variable-tp4810632p4810780.... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
The question is, what should #name: asMutator return 1. #name: because it is already a mutator 2. #name:: because it might be the mutator for variable "name:" Oh, got it. Thanks for the explanation :)
----- Cheers, Sean -- View this message in context: http://forum.world.st/valid-name-for-an-instance-variable-tp4810632p4810883.... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On 10 Mar 2015, at 08:25, Nicolai Hess <nicolaihess@web.de> wrote:
2015-03-09 22:09 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>: Marcus Denker-4 wrote
is x: (with colon) a valid inst var name ? no.
Why complicate the system by special-handling illegal variable names? Just let the incorrect x: become the just-as-incorrect x::, no? Or am I missing something?
No it is not about handling illegal variable names. The question is, what should #name: asMutator return 1. #name: because it is already a mutator 2. #name:: because it might be the mutator for variable "name:"
(2) is how it actually behaves, but because "name:" is not a valid instance variable name, returning #name:: does not makes sense, so I choose option (1).
+1
nicolai
----- Cheers, Sean -- View this message in context: http://forum.world.st/valid-name-for-an-instance-variable-tp4810632p4810780.... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
participants (4)
-
Marcus Denker -
Nicolai Hess -
Sean P. DeNigris -
Sven Van Caekenberghe