Re: [Pharo-project] 1.2: class var #Instance not allowed
On Feb 2, 2011, at 2:32 PM, Igor Stasenko wrote:
2011/2/2 Janko Mivšek <janko.mivsek@eranova.si>:
Hi guys,
One more problem: if some class have a class variable named #Instance, it is not loadable anymore.
It seems that problem is in Class>>bindingOf: method, where check is done in a "declared environment", which happens to be a global SystemDictionary, where a class Instance actually exists.
This means that no class var with a name which collides with a name of class is allowed?
The bug is not in the #bindingOf:
it just answers (correctly) that for given name there are already a binding exists in system. So, it should be allowed to declare the class variable with same name. But there are some nuances: - what to do if supeclass also defining binding for this name? - what if pool dicitonary in (super)class defines binding for given name?
should we allow shadowing of these cases as well, or just for globals?
The question is: was this allowed before in 1.1? Marcus -- Marcus Denker -- http://www.marcusdenker.de INRIA Lille -- Nord Europe. Team RMoD.
On 02. 02. 2011 17:02, Marcus Denker wrote:
One more problem: if some class have a class variable named #Instance, it is not loadable anymore.
The bug is not in the #bindingOf:
it just answers (correctly) that for given name there are already a binding exists in system. So, it should be allowed to declare the class variable with same name. But there are some nuances: - what to do if supeclass also defining binding for this name? - what if pool dicitonary in (super)class defines binding for given name?
should we allow shadowing of these cases as well, or just for globals?
The question is: was this allowed before in 1.1?
It seems yes. I just loaded the same Aida into the latest 1.2 build to test if everything is ok. This is BTW also the fastest way to replay this problem. Just open the Dev workspace and load Aida by a script there. You'll get the next exception: DuplicatedVariableError: Instance is defined elsewhere AIDASite(Class)>>declare:varString ... "check if new vars defined elsewhere" (self bindingOf: var) notNil ifTrue: [(DuplicatedVariableError new) variable: var; signal: var , ' is defined elsewhere'. conflicts := true]]. .... Janko -- Janko Mivšek AIDA/Web Smalltalk Web Application Server http://www.aidaweb.si
Janko Mivšek wrote:
One more problem: if some class have a class variable named #Instance, it is not loadable anymore.
Could you be more specific as to the steps to reproduce? I added a class var named Instance to a class, filed it out, removed the class, and filed it back in with no error. Also, it seems the error is resumable, so won't the class be loaded if you "proceed" on the error? Sean -- View this message in context: http://forum.world.st/1-2-class-var-Instance-not-allowed-tp3253817p3256887.h... Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On 03. 02. 2011 04:27, Sean P. DeNigris wrote:
Janko Mivšek wrote:
One more problem: if some class have a class variable named #Instance, it is not loadable anymore.
Could you be more specific as to the steps to reproduce? I added a class var named Instance to a class, filed it out, removed the class, and filed it back in with no error. Also, it seems the error is resumable, so won't the class be loaded if you "proceed" on the error?
Proceeding on this exception actually continue and successfully load Aida. As said you can reproduce the problem by loading Aida on latest 1.2 build: 1. DEVImageWorkspaces openExternalProjectWorkspace 2. evaluate the Aida loading script there: Gofer new squeaksource: 'MetacelloRepository'; package: 'ConfigurationOfAida'; load. (Smalltalk at: #ConfigurationOfAida) load. Best regards Janko -- Janko Mivšek AIDA/Web Smalltalk Web Application Server http://www.aidaweb.si
One more problem: if some class have a class variable named #Instance, it is not loadable anymore.
Janko Mivšek wrote:
Proceeding on this exception actually continue and successfully load Aida.
So the class can be loaded, and that solves the original problem, right? The current behavior seemed right to me. I think it's good to know that you will be hiding a global by using a certain class variable name. Maybe the issue is that the message isn't clear enough, like it could be "There is global defined with this name, click proceed to add anyway"? Or something to make it more clear that this is a warning and you have to make your own decision. Sean -- View this message in context: http://forum.world.st/1-2-class-var-Instance-not-allowed-tp3253817p3258499.h... Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (3)
-
Janko Mivšek -
Marcus Denker -
Sean P. DeNigris