Re: [MacPerl-Porters] Re: File::Spec catfile etc.

[email protected] (Barrie Slaymaker)
Newsgroups perl.perl5.porters,perl.macperl.porters,perl.vmsperl
Message-ID <[email protected]>
On Sat, Sep 15, 2001 at 09:01:04AM -0700, Peter Prymmer wrote:
> 
> Then what value has adding the warning to:
> 
>      $path = "C:\foo" ;
>      $fullpath = File::Spec->catfile( $path, "bar" ) ;

Here you're asking for portability.

> added to File::Spec?  If I am on win32 and I want to concatenate names
> into a valid win32 file spec I no longer can without specifying:
> 
>      $fullpath = File::Spec::Win32->catfile( $path, "bar" ) ;

There you're telling us that you're manipulating Win32 paths.

If you need to put volume names in, then catpath() is needed.

> Is it not the case that the former implies that I have at least given some
> thought to portability.

Exactly.  The former example is blighted by the (mistyped)

   $path = "C:\\foo" ;

; what I meant to show was that if $path contains a volume spec or a
dirsep, then a warning should be delivered.

> Note that it would have been much easier for
> me to specify:
> 
>      $path = "C:\\foo" ;
>      $fullpath = "$path\\bar" ;
> 
> Rather than using the File::Spec lib module(s).

Yup.

> The problem with the "portability" goal is that on non rooted file systems
> (basically most non-Unix) that there can be no agreeing on full path names
> anyway.

File::Spec's primary goal is portability.  It'll never be 100%, but we
can keep nudging it towards the asymtote.

> Sure I might very well expect to see these on win32:
>
>      A:\
>      C:\
>      D:\
> 
> And I might very well see these on VMS:
> 
>      _SATURN::DKA100:
>      _SATURN::DKA200:
>      _SATURN::DKA300:
> 

See them where?  Passed in to catdir() and/or catfile()?  Or catpath()?

> but why would perl need to remind me that the two sets are different? 

It's not reminding you that they're different; it's warning you when you
use them in a context that is supposed to be portable.  If you're
writing a program on Win32, and a C: or "\\" or even "/" sneaks in,
File::Spec can do you the favor of warning you that you've got some
platform specific bits sneaking in.

> I think that the annoyance of the warnings detracts from the desirablity
> to even use File::Spec to begin with.  My worry is that folks will start
> avoiding it rather than getting to know it.  E.g. look at the
> non-portability of the installperl script.  It currently works only on
> Unix, Windows, and VMS (perhaps other POSIXly oriented environs).  It
> won't work on MacOS at all and ought to use the build
> directorie's copy of File::Spec.
> 
> I suspect, although I have not attempted to code it, that adding the
> various warnings will fill up File/Spec.pm and/or the various
> lib/File/Spec/$osname.pm files with a lot of extra regular expession
> parsing and whatnot that will slow File::Spec down.

There will definitely be a few extra m// ops.  Not sure how important
they are, since actually using a path for anything goes out to the FS
and is therefore likely to be so slow that a few extra m// ops won't be
noticed.  In theory anyway.

The whole idea is for File::Spec to help people use it portably; if you
don't need portability, just hack the paths manually (as you point out)
or use File::Spec::Foo directly.  If we think the warnings are too much
"help", I'm not too worried about adding them.

> Thanks for the help you've given thus far.  Even pulling it out of
> MakeMaker was a challenging task for which I am grateful.

Alas, that was before my time...

- Barrie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.