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. Advertisements

  2. [...]
    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. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.