I just found, that when i tried to redefine previously declared
regular class to a variable one, the ClassBuilder bugs me with error, that 'class can't be recompiled'. Just two doits to reproduce the problem: Object subclass: #Blabla instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Whatever'. Object variableSubclass: #Blabla instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Whatever'. i wonder what the reason of preventing me to redefine a mistakenly defined class, which having 0 methods? And even if i have the methods, so what? I think that this limitation is too strict. I find it quite inconvenient , since now, to redefine a class, i have to rename old one, then define a new one which is variable from a start and then manually copy methods from old one. Another funny thing that i found, that you can actually do: | string | string := 'Blabla'. Object subclass: string instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Whatever'. Smalltalk at: string " returns a class you just defined." Its fun, but having no sense. What is interesting that OB can display this class (but not in a regular way, you can find it in smart groups pane, after searching for 'Blabla'). The above is true for both 3.10 and Pharo-10178 (and i think a more recent Pharo have same behavior). -- Best regards, Igor Stasenko AKA sig. |
Btw, the latter proves, that class naming has nothing to do with
system internals, it only provides a means for developer to identify the class so, then he can use a browsing tools for finding it. This is, of course, not something that i didn't knew before :) Just a thought, that by altering the browser (and some/many other places), one could have classes named as: 'MyPackage.MyClassName' or 'MyNamespase.MyClassName' -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Igor Stasenko
On 10.04.2009, at 05:34, Igor Stasenko wrote: > Another funny thing that i found, that you can actually do: > > | string | > string := 'Blabla'. > Object subclass: string > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'Whatever'. > > Smalltalk at: string " returns a class you just defined." > Yes, reflectively generating classes is what the browser does. And in addition, it is useful for tests. Or in general meta-programming tricks of the evil kind. (e.g. eToys used it to create on-the-fly classes for it's prototype- like object model. In most of these cases, it is better to use anonymous Behaviors, than you don't see them in the browser at all). > Its fun, but having no sense. What is interesting that OB can display > this class (but not in a regular way, you can find it in smart groups > pane, after searching for 'Blabla'). I think this is because the new class is not packaged. The old browser shows it in the class category 'Whatever', indistinguishable from a class created with the browser. Marcus -- Marcus Denker -- [hidden email] http://www.marcusdenker.de |
2009/4/10 Marcus Denker <[hidden email]>:
> > On 10.04.2009, at 05:34, Igor Stasenko wrote: > >> Another funny thing that i found, that you can actually do: >> >> | string | >> string := 'Blabla'. >> Object subclass: string >> instanceVariableNames: '' >> classVariableNames: '' >> poolDictionaries: '' >> category: 'Whatever'. >> >> Smalltalk at: string " returns a class you just defined." >> > > Yes, reflectively generating classes is what the browser does. And in > addition, > it is useful for tests. Or in general meta-programming tricks of the > evil kind. > (e.g. eToys used it to create on-the-fly classes for it's prototype- > like object > model. In most of these cases, it is better to use anonymous > Behaviors, than you don't > see them in the browser at all). > Right, but for common case, this should be errorneous? No? At least Smalltalk>>#at:put: should check that key is symbol. >> Its fun, but having no sense. What is interesting that OB can display >> this class (but not in a regular way, you can find it in smart groups >> pane, after searching for 'Blabla'). > > > I think this is because the new class is not packaged. The old browser > shows > it in the class category 'Whatever', indistinguishable from a class > created with > the browser. I'm not sure what the difference from class created by browser.. A browser IMO should use very same message(s), sent to a class which should be a superclass for newly created new class(es). Doing otherwise would lead to multiple entry points into classes internals, which leads to exponential growth of complexity. > > Marcus > > -- > Marcus Denker -- [hidden email] > http://www.marcusdenker.de > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Igor Stasenko
Igor Stasenko wrote:
> Just two doits to reproduce the problem: > > Object subclass: #Blabla > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'Whatever'. > > Object variableSubclass: #Blabla > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'Whatever'. > > i wonder what the reason of preventing me to redefine a mistakenly > defined class, which having 0 methods? And even if i have the methods, > so what? This is a bug. I could track this to a change somewhere between Squeak 3.2 and Squeak 3.6 (i.e., the bug is not in 3.2 but is in 3.6) where a consistence check was changed from #subclassesDo: to #withAllSubclassesDo:. The test now does a little more than it used to do but it also applies a check that should only be run between two *different* classes (i.e., the subclass and its superclass) to the *same* classes (the superclass and itself). To fix it, change ClassBuilder>>validateSubclass:canKeepLayoutFrom:forSubclassFormat: to have a line saying: subclass == oldClass ifTrue:[^true]. "this ain't no subclass" Please file a mantis bug for this problem. > Another funny thing that i found, that you can actually do: > > | string | > string := 'Blabla'. > Object subclass: string > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'Whatever'. > > Smalltalk at: string " returns a class you just defined." Yeah, I'd say that's another bug. Somewhere there needs to be an #asSymbol in the middle. Can you file another bug for this? Cheers, - Andreas |
2009/4/10 Andreas Raab <[hidden email]>:
> Igor Stasenko wrote: >> >> Just two doits to reproduce the problem: >> >> Object subclass: #Blabla >> instanceVariableNames: '' >> classVariableNames: '' >> poolDictionaries: '' >> category: 'Whatever'. >> >> Object variableSubclass: #Blabla >> instanceVariableNames: '' >> classVariableNames: '' >> poolDictionaries: '' >> category: 'Whatever'. >> >> i wonder what the reason of preventing me to redefine a mistakenly >> defined class, which having 0 methods? And even if i have the methods, >> so what? > > This is a bug. I could track this to a change somewhere between Squeak 3.2 > and Squeak 3.6 (i.e., the bug is not in 3.2 but is in 3.6) where a > consistence check was changed from #subclassesDo: to #withAllSubclassesDo:. > > The test now does a little more than it used to do but it also applies a > check that should only be run between two *different* classes (i.e., the > subclass and its superclass) to the *same* classes (the superclass and > itself). To fix it, change > ClassBuilder>>validateSubclass:canKeepLayoutFrom:forSubclassFormat: to have > a line saying: > > subclass == oldClass ifTrue:[^true]. "this ain't no subclass" > > Please file a mantis bug for this problem. > >> Another funny thing that i found, that you can actually do: >> >> | string | >> string := 'Blabla'. >> Object subclass: string >> instanceVariableNames: '' >> classVariableNames: '' >> poolDictionaries: '' >> category: 'Whatever'. >> >> Smalltalk at: string " returns a class you just defined." > > Yeah, I'd say that's another bug. Somewhere there needs to be an #asSymbol > in the middle. > Can you file another bug for this? > http://bugs.squeak.org/view.php?id=7333 > Cheers, > - Andreas > > > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Igor Stasenko
On 10.04.2009, at 11:29, Igor Stasenko wrote: > 2009/4/10 Marcus Denker <[hidden email]>: >> >> On 10.04.2009, at 05:34, Igor Stasenko wrote: >> >>> Another funny thing that i found, that you can actually do: >>> >>> | string | >>> string := 'Blabla'. >>> Object subclass: string >>> instanceVariableNames: '' >>> classVariableNames: '' >>> poolDictionaries: '' >>> category: 'Whatever'. >>> >>> Smalltalk at: string " returns a class you just defined." >>> >> >> Yes, reflectively generating classes is what the browser does. And in >> addition, >> it is useful for tests. Or in general meta-programming tricks of the >> evil kind. >> (e.g. eToys used it to create on-the-fly classes for it's prototype- >> like object >> model. In most of these cases, it is better to use anonymous >> Behaviors, than you don't >> see them in the browser at all). >> > > Right, but for common case, this should be errorneous? No? > At least Smalltalk>>#at:put: should check that key is symbol. > Ups. I did not realize the string vs. symbol problem... I blame that on the jet-lag ;-) Maybe Smalltalk>>#at:put: could do an #asSymbol? But in general, the whole structural model is not checked too much for consistency. If you do wrong, it will be wrong. Marcus -- Marcus Denker - http://marcusdenker.de PLEIAD Lab - Computer Science Department (DCC) - University of Chile |
Free forum by Nabble | Edit this page |