stevan / p5-mop-redux

A(nother) MOP for Perl 5
139 stars 36 forks source link

How about simplification of attribute declaration #75

Closed yuki-kimoto closed 11 years ago

yuki-kimoto commented 11 years ago

If attribute declaration is only limited to scalar, it will be simplified.

# Now
class Point  {
    has $!x is rw = 0;
    has $!y is rw = 0;

    method set_x($x) {
        $!x = $x;
    }
}

# Simplify or Alias for Scalar attribute
class Point  {
    has x is rw = 0;
    has y is rw = 0;

    method set_x($x) {
        $!x = $x;
    }
}
stevan commented 11 years ago

I don't think this is a good idea to have the definition form be different from the usage form. I appreciate your desire to make it simpler, but I think this goes too far.

forwardever commented 11 years ago

it would also not be clear if

has x is rw = 0;

means

has $!x is rw = 0;

or

has $.x is rw = 0; # which creates accessors in Perl 6

the current implementation seems trying to keep close to Perl 6, which makes a lot of sense long term