Maybe they are complaining about the fact that File::Find does most of its communication through global variables.
Does it really use global variables (err, variables
in the main package; I assume it doesn't use the
truly global punctuation variables, other than for
their intended uses), or does it use package variables
in its own package? The former would be very messy;
the latter isn't nearly so bad. It wouldn't make
sense for an OO module (like DBI), but for a module
with a function interface it seems reasonable
enough to me.
I suspect the OP may be right, and that they may be
complaining about passing anonymous functions around.
Anybody with a solid familiarity with Perl (or any
other language that supports the functional paradigm)
will be reasonably comfortable with this, but a newbie
coming in from another language (especially a
procedural or OO language) may have trouble with it
at first. This is not surprising; it's a different
paradigm than the ones they're familiar with.
They'll also have trouble at first with the list
operators, and if you show them closures you'll want
to have a camera handy to take a snapshot of the
funny looks on their faces. This will pass with
time, as they learn the different paradigms that
Perl supports and why each is useful. (If they
like OO, it may help to tell them that lexical
closures are one way to achieve encapsulation.
That may spark their interest enough to get them
to learn something, instead of turning away in
disgust.)
;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print
| [reply] |
Does it really use global variables (err, variables in the main package; I assume it doesn't use the truly global punctuation variables, other than for their intended uses), or does it use package variables in its own package?
Call them package variables if you want to -- they still meet the definition of "global variable" in most languages, i.e. they are read/write accessible by any code from anywhere. I'm not going to go into a whole explanation of why using globals to pass information, regardless of the use of OO or not, is a really bad design, because many other people have written about it at length. It's not as if these globals are being used internally only -- they are part of the public API for File::Find.
| [reply] |
One can also make the same claim about $DBI::errstr ... globals may be "Bad Things"(tm), but it's not as if they're unusable.
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
| [reply] |