in reply to Re^11: RFC: OO Perl using Moo/Moose book
in thread RFC: OO Perl using Moo/Moose book

Wikipedia says

The term delegation is also used loosely for various other relationships between objects; see delegation (programming) for more. Frequently confused concepts are simply using another object, more precisely referred to as consultation or aggregation; and evaluating a member on one object by evaluating the corresponding member on another object, notably in the context of the receiving object, which is more precisely referred to as forwarding (when a wrapper object doesn't pass itself to the wrapped object).12a The delegation pattern is a software design pattern for implementing delegation, though this term is also used loosely for consultation or forwarding.

So the terminology might be considered imprecise by Wikipedia, but as that terminology and use is far from uncommon, I guess you'll have to rely on the exact definitions given by each writer instead of hoping for a general terminology.

  • Comment on Re^12: RFC: OO Perl using Moo/Moose book

Replies are listed 'Best First'.
Re^13: RFC: OO Perl using Moo/Moose book
by LanX (Saint) on May 01, 2019 at 12:46 UTC
    I saw this already.

    But if Moose claims to implement the generalized term for all "loosely" related concepts, then it should also implement the specialized core meaning.

    Did I miss a possibility to use having such that the method is called with the original $self?

    If yes please show me how. *

    It's like organizing "Pan-American Games" for Argentines and Canadians and excluding US Americans.

    > but as that terminology and use is far from uncommon

    In PHP and some other languages it's common to use "closure" synonymous for "anonymous function".

    I call this bullshit, because neither is every anno function closing over variables from an outer scope nor are named functions excluded from being closures.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

    update

    To avoid misunderstandings, I prefer Forwarding over Delegation, it's much easier to handle.

    But it seems that Perl 6 is the source of this terminology, and that Moose just copied the concept.

    update

    *) does currying allow to change $self?

Re^13: RFC: OO Perl using Moo/Moose book (GoF / Updated)
by LanX (Saint) on May 01, 2019 at 13:30 UTC
      So, the Perl Moo* equivalent would be something like
      package My::Obj; use Moo; has deputy => (is => 'ro', delegates => 'frobnicate');

      where calling $obj->frobnicate(42); would in fact call

      $obj->deputy->can('frobnicate')->($obj, 42);
      ?

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        Yes, looks like the WP definition of "Delegation" to me.

        But I'd say this niche is more or less (?)* filled by "Roles" in Moo/Moose ( of course with different implementation)

        Theoretically speaking. ..

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Update

        *) one difference might be that "deputy" is an attribute of the instance while roles belong to the class.

        As a side note, if you replace "deputy" with "__prototype__" and don't restrict to methods like "frobnicate" you'll have more or less the JS model of inheritance.

        That's why Self and JS are listed as examples for "Delegation".

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice