in reply to Re: [Perl 6] Object methods on the fly?
in thread [Perl 6] Object methods on the fly?
Arguably we could provide syntactic sugar to reduce that to:@array does role { method insert ($x) { @.push($x) unless any(self) eqv $x; } }
Perhaps that use of does is redundant with but= and could be removed, but it does read better, I think. In any case, doing an operation like this on an object ends up creating an anonymous class that derives from the original class and adds in the extra method, so you don't clobber the original Array class.@array does method insert ($x) { @.push($x) unless any(self) eqv $x; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: [Perl 6] Object methods on the fly?
by blazar (Canon) on Jul 19, 2007 at 20:29 UTC | |
by TimToady (Parson) on Jul 25, 2007 at 00:42 UTC |