in reply to Re: Overloading different instances differently.
in thread Overloading different instances differently.
If you were extremely memory concious, you could put each instance's fields in the new package (why use another hashref?)package FOO; sub asdf{shift ; reverse @_}; package main; # need an object so that functions get bound at runtime my $o = bless {}, 'FOO'; print $o->asdf(1..10); # ok undef %FOO::; print $o->asdf(1..10); # function cannot be found
use strict; use Inline 'C'; $\ = "\n"; my $x; BEGIN { my $n = 100; $x = eval 'sub {' . ('%Foo::;' x $n) . '}'; } print refcount(*Foo::); # prints $n + 2 __END__ __C__ int refcount(SV* x) { return SvREFCNT(x); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Overloading different instances differently.
by tilly (Archbishop) on Feb 23, 2008 at 03:48 UTC | |
by lodin (Hermit) on Feb 23, 2008 at 15:51 UTC |