Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Please review the following, if you will:
package TestAnonBefore; use 5.008; use strict; use warnings; use PerlPlusPlus (__PACKAGE__); # ,instance =>'$self'); # $priv_ is optional, $priv_foo is private and will have a private get +ter/setter for this package only # $priv_foo can also be accessed as '$priv_foo' # # $pub_bar is public and will have a public $self->bar getter/setter # # $prot_baz is protected and will have a $self->bar getter/setter only + for subclasses # my($self,$priv_foo,$pub_bar,$prot_baz); # my($self); # can declare $self separately # When sub matches package name, it is constructor # implicit access to $self sub TestAnonBefore { ($pub_bar)=@_; # that's it... } # public instance method, not a getter/setter # getters/setters are generated automatically based on scope (private, +protected,public) sub do_stuff : PUBLIC { $self->do_private; 'Private: ' . $self->foo . ' Public: ' . $self->bar . ' Protected: + ' . $self->baz; # is equivalent to: 'Private: ' . $priv_foo . ' Public: ' . $pub_bar . ' Protected: ' +. $prot_baz; } # sub do_private :Private { sub do_private : PRIVATE { $priv_foo++; } sub stuff{ # same as PUBLIC print "123\n"; } # done declaring a class with PerlPlusPlus no PerlPlusPlus; 1;
Looks familiar to some, and utterly alien to others. What I'm wondering is, is this even a good idea? If someone were to implement a superset of Perl that would obviate the need for
my($self)=@_;
would anyone like/use it? If so, is the preceeding acceptable? What changes would YOU make?? Thanks!

2006-04-08 Retitled by planetscape, as per Monastery guidelines
Original title: 'PerlPlusPlus'

Replies are listed 'Best First'.
Re: RFC: PerlPlusPlus - Better OO
by rhesa (Vicar) on Apr 08, 2006 at 03:06 UTC
Re: RFC: PerlPlusPlus - Better OO
by chromatic (Archbishop) on Apr 08, 2006 at 06:19 UTC

    There are two hacks in Perl Hacks that show how to do that. One uses source filters. The other uses subroutine attributes, B::Deparse, and a sneaky import() trick to obviate the need for invocant declaration.

    (I hate to spoil the trick for anyone who wants to figure it out without help....)

Re: RFC: PerlPlusPlus - Better OO
by Fletch (Bishop) on Apr 08, 2006 at 02:15 UTC

    Erm, yeah. It's alternately called "Perl 6" or by those that actually use it now, "Ruby". :)

      I was totally expecting that response. But answer the QUESTION(S).