Trey wrote:

> I'm wondering about how the sigil-invariance rule interacts with
> attributes.
> 
>   class Foo {
>      attr $bar;
>      attr @bar;
>      method baz {
>          return @.bar[$.bar]; # sigils disambiguate
>      }
>      method frob ($self:) {
>          return $self.bar[$self.bar]; # uh-oh....
>      }
>   }
> 
>

Apparently I don't understand "the sigil-invariance rule." I'm trying to
understand why the return expression is correct in Trey's C<method frob>.
My first reaction was that it should have been
  return @self.bar[$self.bar];
so that the C<@> indicates that we're referring to C<@.bar> rather than
C<$.bar>. 

But that can't be right, since it's C<self> that's the start of the
expression, and it needs its C<$>. So then I realized that there are two
'types' that I think need mentioning: the _scalar_ self, and the _list_ bar.
So then I started thinking along the lines of
  return @{$self}.bar[$self.bar];
and started feeling seriously ill. Of all the peculiarities of Perl 5, that
kind of stuff is what bothers me most.

If everybody's lack of comment on Trey's original formulation was because
there's nothing wrong with it (rather than, say, that everybody overlooked
it), then I'd have to conclude that I've completely misunderstood Larry's
pronouncements on the uses of sigils in Perl 6 -- or missed some important
implications thereof.

Is it fair to conclude that @.bar is inferred by the use of the [square]
subscripts following C<bar>? And can I take that farther and assume that
  simply_impassible . x[0]
for almost any value of C<simply_impassible>, will be referring to a list
named C<x> (or maybe I should say C<@x>), that came from some context
referred to by C<simply_impassible> ... and that this is true no matter what
sigils appear in (or, more to the point, at the beginning of)
C<simply_impassible>?

By the way...is this sort of question appropriate for this mailing list? 

I'm really just a lurker -- and a recent one at that -- and I don't mean to
waste people's bandwidth. So, my apologies in advance if I've asked a dumb
question in the wrong place.
=thom

Reply via email to