lue (>>>), Carl (>>), Jonathan (>):
>>> class A { has $.b; method x { $!b = "b" } }; A.new.x
>>>
>>> this works.
>>
>> Sure, but that doesn't create a class attribute, as was the topic of this
>> ticket. :) The 'has' declarator gives each object instance its own
>> attribute, whereas the ordinary 'my' declarator in a class scope creates a
>> class-wide attribute.
>
> AFAIK, it's just syntactic sugar for declaring a lexical variable and
> generating an l-value method related to it. It doesn't create a $!foo, but a
> $foo. A $!foo is always unambiguously an instance attribute.

It's a bit weak, but S12:711 seems to contradict that:

    my  %!cache is rw;  # generates no public accessor

In my opinion, if the class attribute has a C<.> or C<!> twigil, there
should be a C<!>-twigil version of it.

// Carl

Reply via email to