I think I've created a better perl language by introducing classes, introducing the 'dot' operator, having better private attributes to objects (through Alias's attr operator), introducing the 'new' keyword to create objects, and having arguments for subroutines:
Anyone interested?Code:my $o = new Object; die "didn't work" unless $o.set(_attribute => 3.14); class Object { sub Object($classname){ return bless { _attribute => 0 }; } our $_attribute; sub set($self, %s){ $_attribute = $s{_attribute} || return 0; return 1; } }
(btw, I'm unsure if the above compiles with the new translation)
The real perl code would look like this:
Anyone interested?Code:my $o = Object->Object; die "didn't work" unless $o->set(_attribute => 3.14); package Object; use Alias qw/attr/; sub Object{ my $classname = shift; return bless { _attribute => 0 }; } our $_attribute; sub set{ my $self = attr shift; my %s = @_; $_attribute = $s{_attribute} || return 0; return 1; }
I think packages make objects/classes seem like shrimp food. I think objects/classes should be treated like royalty, and that's why I replacedwithCode:package Object;. Plus the 'dot' operator looks much more better than having to use '->' to access objects.Code:class Object{}
So., is anyone interested in using this style of perl? If so, I could post the code that translates the class-perl to the real perl.



1Likes
LinkBack URL
About LinkBacks





) you could call this YAPOOI-- Yet Another Perl Object Oriented Interface.