On Tue, Mar 18, 2003 at 01:53:59PM +1100, Damian Conway wrote:
: Larry wrote:
: 
: >: sub foo() {
: >:     has $s //= 0; 
: >:     $s ++ ;
: >: }
: >: 
: >: print foo, foo, foo; 
: 
: This is interesting, but I think it would be a mistake to give C<has> two 
: unrelated meanings...

I think it's also a mistake to give C<my> two unrelated meanings.
These are not lexically-scoped variables any more than "our"
variables are, and the fact that they can happen accidentally in
Perl 5 as persistent lexically scoped variables is, er, accidental.
They are lexically scoped aliases to properties of the current block.
Perhaps we should just go with that:

    property $foo = 0;

Or whatever word we choose, I don't care:

    prop $foo = 0;
    have $foo = 0;
    this $foo = 0;
    here $foo = 0;
    block $foo = 0;
    static $foo = 0;    ;-)

But my gut feeling says if it's scoped differently, it had better
have a different introducer.  Scope is too important a distinction
to relegate to a trait of the variable, even though it may be one
from a metadata point of view.  Particularly since we may want it
to warp that assignment notation into an INIT {} or some such.

Actually has/have is kinda cute:

    Each object has...
    We all have...

where "we all" could be taken to mean either "all objects" or "all
invocations of this block".  We could use this for class attributes
and they wouldn't show up globally.  On the other hand the class's
class object isn't quite the same thing as the class's init block.
But we wouldn't have to tell people that...

Whatever.  Important thing is that it has to be out front if it's
a different scope, even if it's not as important a scope as "my".

When you think about it, that's why we have brought "method",
"submethod", "multi", etc. out front too.  These are just scoping
distinctions important to the dispatcher.  But it's important to
human understanding to see that at the beginning.  Submethods aren't
as important as either subs or methods, but it would be a mistake to
make submethodism a mere property of either methods or subs.

In the same way, I think it's a mistake to see a block attribute as
either "our" or "my".

Just don't anyone suggest "submy"...

Larry

Reply via email to