[Pharo-project] Multiple issues with class definition
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.
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 -- denker@acm.org http://www.marcusdenker.de
2009/4/10 Marcus Denker <denker@acm.org>:
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  --  denker@acm.org http://www.marcusdenker.de
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
On 10.04.2009, at 11:29, Igor Stasenko wrote:
2009/4/10 Marcus Denker <denker@acm.org>:
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
participants (2)
-
Igor Stasenko -
Marcus Denker