moving class indepdent methods out of class definitions

Discussion in 'Perl Misc' started by Rainer Weikusat, Mar 7, 2013.

  1. .... and into places where they can be reused by other classes,
    including the possibility to 'overload' them in derived classes (not
    necessarily sensible for class-independent code): Put them into a
    package which exports them. Import them into the class package. That's
    'roles in a nutshell' and the answer is actually so trivial (and
    obvious) that I'm wondering why 'experienced perl programmers' ask
    such questions.
     
    Rainer Weikusat, Mar 7, 2013
    #1
    1. Advertising

  2. Ben Morrow <> writes:

    [...]

    > Quoth Rainer Weikusat <>:
    >> ... and into places where they can be reused by other classes,
    >> including the possibility to 'overload' them in derived classes (not
    >> necessarily sensible for class-independent code): Put them into a
    >> package which exports them. Import them into the class package. That's
    >> 'roles in a nutshell' and the answer is actually so trivial (and
    >> obvious) that I'm wondering why 'experienced perl programmers' ask
    >> such questions.

    >
    > [If you are referring to me, I have made no claims to be an experienced
    > Perl programmer.]
    >
    > That's doable, certainly, and is indeed a simple-minded implementation
    > of roles.


    It is a way to move class independent code out of classes into
    packages which enable this code to be used as methods by any class
    which provides a 'suitable interface' for accessing 'instance state'
    which works with plain Perl 5. I'll mark this as a 'possibly useful
    idea' for future problems but so far, I haven't missed it.
     
    Rainer Weikusat, Mar 8, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. no spam
    Replies:
    29
    Views:
    762
    Dave Thompson
    Jan 24, 2005
  2. George
    Replies:
    1
    Views:
    336
    Victor Bazarov
    Nov 8, 2007
  3. linkswanted
    Replies:
    0
    Views:
    1,268
    linkswanted
    Dec 21, 2007
  4. Kenneth McDonald
    Replies:
    5
    Views:
    373
    Kenneth McDonald
    Sep 26, 2008
  5. lars van gemerden
    Replies:
    4
    Views:
    254
    Dennis Lee Bieber
    Jun 28, 2012
Loading...

Share This Page