On Sun, Mar 16, 2003 at 04:22:27PM +0200, arcadi shehter wrote: : it's interesting that "has" have more or less required scope -- its : visible only from object methods and it keeps its value , so maybe : something like this : : : sub foo() { : has $s //= 0; : $s ++ ; : } : : print foo, foo, foo;
That's a *very* interesting idea, but I would have to convince myself that we're not merely overloading "has" the way C overloaded "static". I suppose I could convince myself that there is some permanent "subish" descriptor object that can "have" the attribute. Another question is whether a class containing methods containing "has" would be confusing. The $s vs $.s distinction seems to help a bit there. That would seem to imply that class foo { has $s; has $.t; } declares a class attribute vs an instance attribute. But I don't really like using the same keyword for two different scopes. And I'd rather use the $s vs $.s distinction to indicate whether accessor methods should be autogenerated, if we even allow "has $s". Still, if anything that is not a class considers itself to be a class with a singleton object, then the distinction between class variables and instance variables is moot, and "has" could be taken to refer to that singleton object's values. I guess the real question would be, is it an overall simplification to allow "has" anywhere? There *is* an object out there representing each abstract closure (pre-instantiation), but it's a bit of a stretch from "Every block is a closure" to "Every block is a closure that is also an object except that the object in question doesn't participate in the closure's closure, as it were." On the other hand, it's the block itself that is that abstract pre-closure object, so running it the other way would mean stretching our minds into thinking "has" always sets block properties, and that every object is a funny kind of block. I dunno. Probably people wouldn't think about "has" on that level. People are pretty good at overloading resolution without finding deep connections between the different uses of the word. Larry