develooper Front page | perl.perl5.porters | Postings from August 2001

Re: minor File::Spec questions

Thread Next
Barrie Slaymaker
August 21, 2001 05:21
Re: minor File::Spec questions
Message ID:
[CCing p5p]

On Mon, Aug 20, 2001 at 11:22:31PM -0400, David Boyce wrote:
> Barrie,
> Just a couple of nits. First, I keep wondering something about the way 
> File::Spec is documented. If I run "perldoc File::Spec" or similar I see 
> overview material followed by this statement:
>       For a list of available methods, please consult the
>       File::Spec::Unix manpage, which contains the entire set, and
>       which is inherited by the modules for other platforms.
> So I run "perldoc File::Spec::Unix" instead. This pattern is repeated 
> frequently, for me at least, and is particularly counteruintuitive when I 
> need details on a File::Spec::Win32 method. Why isn't the canonical method 
> documentation in File::Spec instead of a platform-specific subclass? 

I don't know, I came late to the party.  I think that the ::Unix
semantics are the most pervasive, several of the other ::Foo modules
inherit from it.  It's "first among equals", so I guess the
documentation follows it.

I think it would be good if perldoc File::Spec gave all the routines'
names, calling examples, and descriptions.  It's certainly the most
logical place to look.  Care to patch?  I'm pretty swamped right now...

> Another nit which it's probably way too late to fix: technically it should 
> be File::Spec::UNIX (all caps).

It's definitely moot, either way would confuse equal numbers of people
(both forms are common), and even Ritchie seems to prefer "Unix" these
days according to lore:

> Last, I don't know if this rationalization has been suggested before: it 
> seems to me that File::Spec is the logical place for basename/dirname 
> functions now that it's in the core. Have you considered moving the 
> relevant  File::Basename code into File::Spec and replacing File::Basename 
> with a compatibility wrapper that provides a functional interface to 
> File::Spec->basename() et al? It seems that whenever I use one of these I 
> need to use the other too and I find the the different namespaces and 
> styles (OO vs functional)  somewhat jarring.

The whole OO interface to File::Spec bugs me, and I still use it out of
habit when I could use File::Spec::Functions.  I proposed rewriting it
to be functional with an OO wrapper, but nobody on p5p seemed
interested, so I haven't bothered.  I did build a large test suite
(never large enough :-) starting down that path, though.

File::Spec::Functions handles most of the interface needs nicely when
going for portability (as opposed to cross-platform operation where you
might want to play with Unix style paths on a Mac, say), and the speed
of File::Spec just doesn't get complained about.

So, the performance isn't an issue, the functional interface is good
enough for 99.9% of uses, and fixing what isn't broken is asking for

- Barrie

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About