in reply to -foo not readonly in fun(-foo => 1) in perl v5.8.7
I wanted to use Scalar::Util::readonly() to help distinguish between foo( 1,2,3) and foo( -one => 1, -two => 2, -three => 3),
That brings to mind "and I wanted a pony".
If you had come to me with that idea, I would have told you that you need to solve your problem in a different way. Even if you hadn't already found out that your trick is broken for some environments, I would have warned you that your idea is inherently fragile. It will be broken by a matter of optimization within Perl. There is no guarantee of the behavior that you assumed.
It is also extremely fragile in the face of simple changes to how your code is used. You should feel guilty considering making code that breaks between these two usages:
foo( -bar => 1 ); my %args= ( -bar => 1 ); foo( %args );
I think the better alternative is nearly obvious so I won't spend time describing it at this time.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: -foo not readonly in fun(-foo => 1} in perl v5.8.7 (wishes)
by Jenda (Abbot) on Apr 20, 2008 at 08:23 UTC |