On Tue, Nov 04, 2003 at 11:18:36AM +0100, A. Pagaltzis wrote: > * 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'm guessing you didn't read my code because it was based on Yves'. Yves showed a single accessor method called inside_out, you complained that it would requir lots of typing of refaddr to use that for every attribute in the class so I gave an out-of-band accessor method _maker_. The idea being you could just do use My::OutOfBandLexicalThing qw( Attr Attr2 Attr3 ); and you'd get lexically scoped, overload worry free, out of band attrs without any bothersome typing. > 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. Since the exported closure was the only thing that let you access %attrib, putting it inside %attrib rather than exporting it would definitely reduce the accessibility of the attribute :-) FThread Previous | Thread Next