On Dec 24, 2003, at 1:23 PM, R. Joseph Newton wrote:
drieux wrote:

cf: <http://www.wetware.com/drieux/pbl/Sys/FS/dir_walk.plx>
[..]

CAVEAT: this is not a call for the return to 'town/gown' kvetching.
the fact that I was victimized by latin, greek and hebrew
in my formative years is not meant to rally 'the old school ties'
against the heathens of the unwashed masses...

OTOH, the too-quick recourse to packaged functionality can
short-circuit the development of skills,
and more importantly, conceptual mastery, for the student.

There is also the problem of


ceteris paribus ( latin for "all things being equal" )

that swings both ways. Many of the 'best practices' that
we have are derived from some set of personal experience,
or faith in the kvetching of another who is alledged to
have had a good reason for doing it that way.

If anyone drops that dir_walk.plx into their pet
perl debugger { which I highly recommend, nothing is
quite as Frightening a moment as watching what code
really does, than watching it roll over the rollers
in the perl debugger... besides building out one's debugging
skill set will impress your Friends, CoWorkers, and GenderAppropriatePerkin }
they may pause and ask themselves about


DB<1>
File::Spec::Unix::canonpath(/System/Library/Perl/5.8.1/File/Spec/ Unix.pm:46):
46: if ( $^O =~ m/^(?:qnx|nto|cygwin)$/ && $path =~ s:^(//[^/]+)(/|\z):/:s ) {
DB<1>


and wonder why it is that if they were planning to only
use the code on a *nix box, they should have made the step
out to File::Spec on the off chance that it might some day
be used on a VMS box.

The problem here of course is that one has either stepped
off to 'isolate' their OS/FS specific code in a module so
that only that Module will need to be 'upgraded' to use
say File::Spec, and/or other OS specific Modules, Or one takes
the same ceteris paribus approach and opts to buy the
general case solution to begin with...

As a part of the ongoing struggle we note that the
code at
<http://www.wetware.com/drieux/pbl/Sys/FS/unix_dir_walk.plx>
differs only from the more generic code with:

< my $start_dir =  "$ENV{HOME}/tmp/Wetware";
---
> my $start_dir = File::Spec->catdir( $ENV{HOME},  qw/tmp Wetware/ );
62c65
<         my $path = "$dir/$filename" ;
---
>         my $path = File::Spec->catfile( $dir, $filename );

So I am more than willing to support the canonical Jihaud Du Jure
about the orthodox model for coding...

{
subtle sub_text - both codes use
        my @allfiles = File::Spec->no_upwards( readdir DIR );
}

MAJOR WARNING:

there is this minor issue with 'symbolic links' that can
become nasty - what I like to refer to as the 'jeff foxworthy
problem'[1][2] - since it is possible to have an entry of the form

looper -> ../../

that would create an infinite loop in a simple recursive
code as originally advertised. This will not be cleaned up
by simply using File::Spec - and folks should plan to
deal with this class of issues.

I see recursion as an essential concept for developing programmers
to grasp and integrate,
[..]

I had not intended to get into the
'jeff foxworthy problem' - since one of the
hardest functional part of doing 'recursion' is
making sure that all of the 'exit conditions' are
cleanly covered....

But since we were taking the time to step into the
problem of Production v. Pedagogy I thought I would
take the time to both raise the issue of 'when is it
optimization' and that way of course logically leads
me to the inevitable problem of getting out of logical loops.

So while it is easier to solve that in the simpler case
of file system looping, it is less clear how one exits
gracefully from the problem of 'ceteris paribus',
all things being equal, except that as one grows out
their experience they figure out which are their personal
pet collection of 'inclinations' and sticks to them to
avoid the problems they know about...


ciao drieux

---

[1] for our non american reader's the gag is

        you might be a redneck if your
                family tree has any loops in it

tree_traversing needs to be able to manage this
sort of 'looping' issue - since whether it is a
file system that allows 'symbolic links' - or any
other form of hierarchical structure, if the system
allows for a 'loop'.... well, one needs to resolve
when it is time to get out of the loop...

[2] in my next life I get to get out of the habit of footnoting...


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to