in reply to Why does exists cause autovivication?
exists has never had any special power over auto-vivification at all. See Re^10: searching a list (myth) for a full explanation of that.
See Data::Diver for an alternate solution. Well-considered suggestions for improvements welcome; I'm quite sure there is ample room for improvement.
Rather than "fix" exists to prevent auto-vivification, I'd prefer to have a pragma that makes auto-vivification a fatal error (or optionally a warning). There are times when I program very carefully and any case of autovivification is quite simply the indication of a bug. It is a rather like "use strict" or like the "Use of uninitialized value" warning. There are often times where the restrictions imposed by such things are inconvient (one-liners in the case of "use strict") but there are other times where enforcing "extra care" is a real boon.
I also think such a pragma would be easier to implement than changing exists. Also, once you have the pragma, it makes it easier to give that power to exists as well -- since the pragma requires a flag for "don't auto-vivify" that can be attached to op-nodes (that is how lexical pragmata work) and "fixing" exists would require the same flag.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why does exists cause autovivication? (myth, mods)
by Dumu (Monk) on Jul 09, 2015 at 09:24 UTC | |
by tye (Sage) on Jul 09, 2015 at 17:18 UTC |