logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Undeclared attributes: msg#00213

Subject: Re: Undeclared attributes
Dave Whipp wrote:
Attributes are declared with C<has>, but also have a unique signil C<$.>. So is it strictly necessary to declare them? Or rather, is it C<no strict>ly necessary -- i.e. is the following legal?

no strict;
class Foo {
  method bar {
   say $.a++
  }
}


For the standard layout, I'd think it'd be good to declare the
attributes, but perhaps not necessary. An object of class C, IIRC, will
just be an object in the parrot sense; doing an C<addattribute Px, Sy>
will cause the attribute to be added to all other objects of that class,
 and to all objects that "is" or "does" that class; That might involve
a whole lot of work.

But maybe you are asking if Perl6 can intuit that you implied an
unwritten C<has $.a>.... But it could be a C<has $.a> or C<our $.a> or
C<my $.a>.

BTW, should we be able to write pragmas like this:

class Foo isnt strict{...}

or

class Foo isn't strict{...}


--abhijit





<Prev in Thread] Current Thread [Next in Thread>