On Wed, 2004-04-21 at 12:44, Abhijit A. Mahabal wrote:
> On Wed, 21 Apr 2004, Brent 'Dax' Royal-Gordon wrote:
> > Which actually brings up an interesting question:
> >
> >      class Silly {
> >          has $.thing=1;
> >          has @.thing=(2, 3);
> >          has %.thing=(4 => 5, 6 => 7);
> >      }
> 
> I had assumed that'd be illegal: each of $.thing, @.thing and %.thing
> autogenerates a method named thing. I would hope that is illegal, for my
> head would hurt otherwise keeping track of what a particular "thing"
> means.

Certainly makes sense to me. The default constructor for Class should be
able to handle this case quite cleanly by throwing an exception the
moment you try to re-define an existing accessor, which would only yield
a warning elsewhere.

Now, just thinking out loud, but that should leave:

        class c1 { has @.joe }
        class c2 { is c1; has $.joe }

alone because you're not replacing an accessor, you're defining one that
will be hit first by the dispatcher. You are essentially saying that
c2's joe is a scalar, not an array which makes fine sense.

Similarly, if joe were a method in c1, it would still be "replaced" in
the same way. This might lead to some surprises, but I think if folks
understand the relationship here correctly, it will not be an issue.

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to