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

Re: Class::FakeAttributes -- Opinions Wanted

Thread Previous | Thread Next
From:
A. Pagaltzis
Date:
November 4, 2003 02:19
Subject:
Re: Class::FakeAttributes -- Opinions Wanted
Message ID:
20031104101836.GA6978@klangraum
* fergal@dyn.fergaldaly.com <fergal@dyn.fergaldaly.com> [2003-11-04 10:49]:
> What else do you mean by "tightly scoped"?

Something like this:

* Orton, Yves <yves.orton@de.mci.com> [2003-11-03 17:34]:
>   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)};
>       }
>    }
>   }

I guess you can reduce the accessibility of the attribute by
storing the closure ref in a lexical scoped like %attrib in the
above code instead of exporting it to a named sub.

I also guess I'm belabouring a minor point.

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