moving class indepdent methods out of class definitions

  • Thread starter Rainer Weikusat
  • Start date
R

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

Rainer Weikusat

[...]
Quoth Rainer Weikusat said:
... 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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top