Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Re: Often Overlooked OO Programming Guidelines

by hardburn (Abbot)
on Dec 29, 2003 at 22:00 UTC ( #317567=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Often Overlooked OO Programming Guidelines
in thread Often Overlooked OO Programming Guidelines

Holding refs to subroutines seems like a perfectly good way to do private methods:

package Foo; . . . my $fiddle = sub { my $self = shift; return map { scalar reverse $_ } @_; }; sub wonk { my $self = shift; $self->$fiddle(@_); } package Bar; sub wonk { my $self = shift; $self->$fiddle(@_); # runtime error }

The real problem is that Perl doesn't have a good way of denoting protected methods or attributes. I don't consider litering your code with $obj->isa( . . . ) or die; to be a good way.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated


Comment on Re: Re: Re: Often Overlooked OO Programming Guidelines
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://317567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2015-07-04 03:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls