develooper Front page | perl.perl6.language | Postings from March 2005

Re: MMD as an object.

Thread Previous | Thread Next
From:
Rod Adams
Date:
March 9, 2005 04:21
Subject:
Re: MMD as an object.
Message ID:
422EE9CD.9010309@rodadams.net
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 have to be junctive because for a multi it's irrelevant
> if it's a method or a sub. This distinction is used only at compile
> time of the class closure. So I guess there is a
>
> class Multi is Code {...}
>
> in Perl 6.

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.

>
>> 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 
>> example.
>
>
> I see. Something like
>
> use MMD::Manhattan;
> use MMD::Symmetric;
> use MMD::Pattern;
> ...

I was thinking more along the lines of :

    use MMD::Pattern;

    our &func is MMD::Pattern;

    multi func (...) {...}
    multi func (... ...) {...}
    multi func (... ... ...) {...}

    multi func2 (...) {...}
    multi func2 (... ...) {...}
    multi func2 (... ... ...) {...}

Where &func would get Pattern MMD, and func2 would get Manhattan MMD.


-- Rod Adams


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About