Re: MMD as an object.

2005-03-11 Thread Rod Adams
Leopold Toetsch wrote: Rod Adams <[EMAIL PROTECTED]> wrote: If I were to need a different policy for a given method .bar, I would likely create something called .bar much like your "run_random_bar", which then dispatches amongst methods I name something like ._bar . I see some detractions t

Re: MMD as an object.

2005-03-11 Thread Leopold Toetsch
Rod Adams <[EMAIL PROTECTED]> wrote: > If I were to need a different policy for a given method .bar, I would > likely create something called .bar much like your "run_random_bar", > which then dispatches amongst methods I name something like ._bar . > I see some detractions to this approach: > 1)

Re: MMD as an object.

2005-03-11 Thread Rod Adams
Leopold Toetsch wrote: Ok. If you'd really need such random dispatch, it could be done like this, when I interpret A12 correctly: sub run_random_bar($x) { my @meths = WALKMETH($x, :method('bar')); my $meth = @meths[rand(@meths.elems)]; $meth($x); } or even with my sub bar($x) {...} #

Re: MMD as an object.

2005-03-11 Thread Miroslav Silovic
[EMAIL PROTECTED] wrote: Ok. If you'd really need such random dispatch, it could be done like this, when I interpret A12 correctly: sub run_random_bar($x) { my @meths = WALKMETH($x, :method('bar')); my $meth = @meths[rand(@meths.elems)]; $meth($x); } or even with my sub bar($x) {...}

Re: MMD as an object.

2005-03-11 Thread Bob Rogers
From: Leopold Toetsch <[EMAIL PROTECTED]> Date: Thu, 10 Mar 2005 10:53:11 +0100 Rod Adams <[EMAIL PROTECTED]> wrote: > It seems to me that there are several advantages to making a group of > multi with the same short name a single object, of type > MultiSub|MultiMethod, which int

Re: MMD as an object.

2005-03-11 Thread Leopold Toetsch
Rod Adams <[EMAIL PROTECTED]> wrote: > Leopold Toetsch wrote: >>Discussion seems to have went off into esoteric cases of locally >>overriden dispatcher policies and what not. > I don't think it's as esoteric as you might think. Consider: > package Foo; > use MMD::Random; > our &bar

Re: MMD as an object.

2005-03-11 Thread Leopold Toetsch
Bob Rogers <[EMAIL PROTECTED]> wrote: >From: Leopold Toetsch <[EMAIL PROTECTED]> >1) is there a MultiSub object with one short name that holds all >possible long names (and function references)? >If yes, who is creating it: the Perl6 compiler emits code to do so or >it's up to

Re: MMD as an object.

2005-03-10 Thread Rod Adams
David Storrs wrote: On Thu, Mar 10, 2005 at 02:22:20PM -0600, Rod Adams wrote: David Storrs wrote: On Wed, Mar 09, 2005 at 03:38:52PM -0600, Rod Adams wrote: use Foo; # from above, exports &bar is MMD::Random multi sub bar {...} Does this generate an error, since one could expect thi

Re: MMD as an object.

2005-03-10 Thread David Storrs
On Thu, Mar 10, 2005 at 02:22:20PM -0600, Rod Adams wrote: > David Storrs wrote: > >On Wed, Mar 09, 2005 at 03:38:52PM -0600, Rod Adams wrote: > >> use Foo; # from above, exports &bar is MMD::Random > >> multi sub bar {...} > >> > >>Does this generate an error, since one could expect this particu

Re: MMD as an object.

2005-03-10 Thread Rod Adams
Leopold Toetsch wrote: Rod Adams <[EMAIL PROTECTED]> wrote: It seems to me that there are several advantages to making a group of multi with the same short name a single object, of type MultiSub|MultiMethod, which internally holds references to the all the various routines that share that short

Re: MMD as an object.

2005-03-10 Thread Rod Adams
David Storrs wrote: On Wed, Mar 09, 2005 at 03:38:52PM -0600, Rod Adams wrote: There lingers the case of: use Foo; # from above, exports &bar is MMD::Random multi sub bar {...} Does this generate an error, since one could expect this particular &bar to be Manhattan? Or does it assume Ran

Re: MMD as an object.

2005-03-10 Thread Miroslav Silovic
[EMAIL PROTECTED] wrote: What about multi subs? They can be defined everywhere. Given: multi sub *foo(A $a, B $b) {...} Is this something like: %globals{"foo"} --> MultiSub{"foo_A_B" => Sub, ...} What about a not so global multi: multi sub foo(A $a, B $b) {...} Thanks for clarifying, leo Uh

Re: MMD as an object.

2005-03-10 Thread David Storrs
On Wed, Mar 09, 2005 at 03:38:52PM -0600, Rod Adams wrote: > There lingers the case of: > >use Foo; # from above, exports &bar is MMD::Random > >multi sub bar {...} > > Does this generate an error, since one could expect this particular &bar > to be Manhattan? Or does it assume Rando

Re: MMD as an object.

2005-03-10 Thread Leopold Toetsch
Rod Adams <[EMAIL PROTECTED]> wrote: > It seems to me that there are several advantages to making a group of > multi with the same short name a single object, of type > MultiSub|MultiMethod, which internally holds references to the all the > various routines that share that short name. Discussion

Re: MMD as an object.

2005-03-10 Thread Miroslav Silovic
[EMAIL PROTECTED] wrote: It would behave like a tied sub (or method), with a .dispatch method to decide which of the contained routines should be called this particular time. Manhattan would be the default. However, one can override the dispatch logic; implementing Luke's Patterns idea, for exa

Re: MMD as an object.

2005-03-09 Thread Rod Adams
Larry Wall wrote: On Wed, Mar 09, 2005 at 06:19:25AM -0600, Rod Adams wrote: : I was thinking more along the lines of : : :use MMD::Pattern; : :our &func is MMD::Pattern; : :multi func (...) {...} :multi func (... ...) {...} :multi func (... ... ...) {...} : :multi func2

Re: MMD as an object.

2005-03-09 Thread Larry Wall
On Wed, Mar 09, 2005 at 06:19:25AM -0600, Rod Adams wrote: : I was thinking more along the lines of : : :use MMD::Pattern; : :our &func is MMD::Pattern; : :multi func (...) {...} :multi func (... ...) {...} :multi func (... ... ...) {...} : :multi func2 (...) {...} :

Re: MMD as an object.

2005-03-09 Thread Thomas Sandlaß
Luke Palmer wrote: Keep in mind that the two following definitions are equivalent: class A { method foo () {...} } multi sub foo (A $a) {...} Except for attribute access, I think. For public attrs the accessor is not used and private ones are available: class A { has $.pub = "pub"; ha

Re: MMD as an object.

2005-03-09 Thread Luke Palmer
Rod Adams writes: > I wasn't intending it to be junctive. I was just noting that you needed > separate holders for subs and methods, since you shouldn't be able to > stuff a method into a multi sub. Keep in mind that the two following definitions are equivalent: class A { method foo () {...

Re: MMD as an object.

2005-03-09 Thread Rod Adams
Thomas Sandlaß wrote: Rod Adams wrote: It seems to me that there are several advantages to making a group of multi with the same short name a single object, of type MultiSub|MultiMethod, which internally holds references to the all the various routines that share that short name. It doesn't hav

Re: MMD as an object.

2005-03-09 Thread Thomas Sandlaß
Rod Adams wrote: It seems to me that there are several advantages to making a group of multi with the same short name a single object, of type MultiSub|MultiMethod, which internally holds references to the all the various routines that share that short name. It doesn't have to be junctive becaus

MMD as an object.

2005-03-08 Thread Rod Adams
It seems to me that there are several advantages to making a group of multi with the same short name a single object, of type MultiSub|MultiMethod, which internally holds references to the all the various routines that share that short name. It would behave like a tied sub (or method), with a .