develooper Front page | perl.module-authors | Postings from November 2003

Re: Class::FakeAttributes -- Opinions Wanted

Thread Previous | Thread Next
From:
A. Pagaltzis
Date:
November 3, 2003 08:50
Subject:
Re: Class::FakeAttributes -- Opinions Wanted
Message ID:
20031103164936.GB17108@klangraum
* Orton, Yves <yves.orton@de.mci.com> [2003-11-03 17:34]:
> in hind site implementing an inside out object/attribute is so
> easy (its pretty small, heres what I use for good general
> coverage:)
> 
>   use Scalar::Util qw(refaddr);
> 
>   {  
>    my %attrib;
>    sub inside_out {
> 	my $s=shift;
>       if (@_) {
>           $attrib{refaddr($s)}=shift;
>           return $s;
>       } else {
>           return $attrib{refaddr($s)};
>       }
>    }
>   }
> 
> The refaddr is useful because it allows for $s to have
> stringification overloaded.

Precisely this bugs me about it.. you have to type out the
refaddr everywhere; and even without overloading, there's good
reasons not to just write $self (but stuff like 0+$self or
whatever).

And then there's accessor/mutator generation.. ie what
::MethodMaker does. Which there seems to be no easy way to do
(with lexicals) using inside out objects..

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About