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