Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2019-09-23 07:14 GMT
Find Nodes?
    Voting Booth?
    The room is dark, and your next move is ...

    Results (277 votes). Check out past polls.