Subject: | IO::All::Base::option calls field with caller = "IO::All::Base" |
% perl -wle 'use IO::All::Base (); BEGIN { print defined
&IO::All::Base::_strict ? "yes" : "no"; } use IO::All (); BEGIN { print
defined &IO::All::Base::_strict ? "yes" : "no"; }'
no
yes
So what's going on here is that I had a look at &option in IO/All/Base.pm
(while looking for the implementation of &io, but that's a separate issue).
IO/All.pm calls option('strict'), which in turn calls field('_strict',
1). The
funny thing is that both &option and &field are "magical" in that they use
their caller's package to decide where to put the generated sub.
The problem is that &option calls &field, and in that case &field's
caller is
always "IO::All::Base". In other words, every call to option("foo") from
anywhere creates a field in IO::All::Base::_foo. I'm not sure how this
interacts with inheritance but I think it means if any subclass of IO::All
creates an option foo, then suddenly all other subclasses gain a field _foo.
I don't think this is the intended behavior.