blazar has asked for the wisdom of the Perl Monks concerning the following question:
Ok, this is basically a repost of a part of Re^3: [Perl 6] Object methods on the fly?, in which I probably asked too many further side questions, all of which OT wrt the main thread. So I'm asking again here in the hope that it will have more visibility...
I tried the following in pugs:
pugs> my @array does role { ....> multi method insert ($x) { @.push($x) if none(self) eqv $x } ....> multi method insert (@x) { @.insert($_) for @x } ....> } = 1..5; (1, 2, 3, 4, 5) pugs> @array.insert($_) for 2..6; pugs> say @array 123456 Bool::True pugs> @array.insert(3..7); pugs> say @array 12345634567 Bool::True
I would have expected the second say() to similarly print 1234567. (If I use *@x, pugs "hangs", instead.) Did I miss something or is perhaps this only a specific implementation, namely pugs, problem?
Update: TimToady answered in the context of the original thread:
Finally, I think the failure of the multi form is just hitting some things that aren't completely implemented in pugs yet.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [Perl 6] Problem with multi methods
by chromatic (Archbishop) on Jul 23, 2007 at 17:25 UTC | |
by blazar (Canon) on Jul 23, 2007 at 17:55 UTC |