in reply to Re^2: why "Bless" in OO Perl
in thread why "Bless" in OO Perl

You are absolutely correct. ...it's a concept I understand but have difficulty expressing clearly, especially in a layman vocabulary. Good job with the linguistic deobfuscation. ;)

I might add, the referent needn't be a hash, a simple scalar, nor an array. It could also be a file handle, a regexp, and even a sub, though I've never figured out a useful purpose to blessing a sub. Now I'm sure someone will follow-up with a brilliant use of this technique. *grin*


Dave

Replies are listed 'Best First'.
Re^4: why "Bless" in OO Perl
by Roy Johnson (Monsignor) on May 03, 2006 at 17:34 UTC
    OO: extending a closure object was an example of using a closure as an object base type. The blessed sub is the only possible accessor. It allowed the object to be very opaque, but I didn't see it as enough of a benefit to recommend it.

    Caution: Contents may have been coded under pressure.
Re^4: why "Bless" in OO Perl
by Fletch (Bishop) on May 03, 2006 at 17:54 UTC

    Not brlliant but see Re: How to store CODE ref for a method of accessing the source for a coderef without resorting to B:: trickery (of course it's not perfect since it doesn't preserve closureness, but then that's a hard problem no matter what . . .).

    Update: Never mind, that's not blessing the coderef directly it's overloading &{}. I thought I'd done something similar with blessed coderefs. Hrmm . . .