[squeak-dev] re: About classVariables
eliot.miranda at gmail.com
Mon Oct 13 23:16:38 UTC 2008
On Mon, Oct 13, 2008 at 1:20 PM, Craig Latta <craig at netjam.org> wrote:
> Hi Eliot--
> > Whoever said that the class variables of a metaclass should be those
> > of Metaclass is very wrong. Code compiled in the context of a
> > metaclass includes the class variables of the non-metaclass
> > (metaclass's instance), otherwise one couldn't access class variables
> > in class-side methods.
> I think you're confusing metalevels. If I compile a class-side method
> for Array, and I use a class variable, conceptually it's one of Array's
> class variables I'm using, yes? What the class variables of (Array class)
> might be is irrelevant. Yes, during compilation, Metaclass>>scopeHas:ifTrue:
> delegates to the receiver's sole instance, but that doesn't mean that a
> metaclass has the same class variables as its sole instance.
When compiling code in Foo class, as opposed to Foo, the compiler
asks Foo class to lookup variables, not Foo. Hence if the code refers to a
class inst var of Foo it will be in scope because this class inst var will
be one of Foo class's inst vars. Similarly, when the compiler asks Foo
class to bind a variable that is actually a class variable of Foo, it is up
to Foo class to look in Foo's class pool, not the compiler.
So it makes sense to me that Foo class's class pool is the same as Foo's.
To say otherwise is to introduce a conceptual inconsistency into the
> system: the class variables of an object are defined by its class, except if
> that object is a metaclass. Further, suppose the class variables pool for
> Metaclass were not empty. By your logic instances of Metaclass don't have
> access to it.
The only place that instances of Metaclass have access to Metaclass's class
pool is in methods on Metaclass. Class-side methods in metaclasses other
than Metaclass class do _not_ have access to Metaclass class variables. Try
> I guess we disagree here.
> Craig Latta
> improvisational musical informaticist
> Smalltalkers do: [:it | All with: Class, (And love: it)]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev