May 28, 2012

Perl Core Syntax Wishlist: Class support

I would like to see the class keyword become part of Perl, but unlike some I don't want it simply because it's nicer syntax. I'd like it to behave differently from package. I'd basically like to see this I'm sure smarter people than I could think of a few more things that might be nice to have by default in all classes. I would like to note that method signatures is not that big of a deal to me, unless of course you want to give me named variables in the signature besides just auto shifting off self, e.g. method foo ( $bar ) { return $self->{foo} if $bar }

6 comments:

  1. This does most (if not all) of what you want.

    http://search.cpan.org/perldoc?MooseX::Declare

    ReplyDelete
  2. That doesn't work for me for about 4 reasons

    4. It's slow, slower than moose IIRC

    3. I've had problems with it actually working. IIRC it did not like me putting Classes and Role's in the same file when I was trying to write a quick prototype.

    2. My Boss has a case of NIHS, and no deps outside of Perl.

    (MOST IMPORTANT)
    1. we should not, stop adding syntax to Perl because of cpan modules being able to do it. I wrote this to show how class could be a new keyword that was more than an alias for package.

    ReplyDelete
  3. We are working on this right now (https://github.com/stevan/p5-mop), now sure exactly what release of Perl it will be in (I am hoping 5.18 but would be happy with 5.20).

    ReplyDelete
  4. I'd like to see any support of any MOP be experimental at first... so hopefully 5.18 experimental. 5.20 stable. I basically fear bad API being introduced (not that I'm saying the people on it would do a bad job ) simply that such things may need some time to have the API ironed out.

    ReplyDelete
  5. also +10 on work already in progress.

    ReplyDelete

Note: Only a member of this blog may post a comment.