On Thu, Apr 21, 2005 at 08:22:29AM +0200, Johan Vromans wrote:
: >From the perspective of 'current directory' there should also be a
: simple and elegant way that will do in most cases. Advanced tricks can
: be made possible using separate modules and such.

Yes, easy things should be easy, and hard things possible.

: Maybe the basic problem is that 'current directory' is a system
: dependent file system location that is not a fixed string, although it
: usually can be represented as a string. Similar to a simple 'open', I
: think the most common use of 'cwd' (or whatever) is to return a file
: system location that can be returned to later, much in the sense of
: 'tell' and 'seek'. I think this can be implemented in a quite fail
: safe way on most platforms.

I kinda like the proposed @CWD interface, insofar as it abstracts out
the most system-dependent part of the filename, the delimiter.  Since
Perl 6 is throwing away $" in favor of a per-array property, that
property could simply be "/" for Unixish filenames.  Then we can write
things like:

    temp push @CWD, "subdir" err die "Can't chdir: $!";

I still think @CWD should try to track the actual directory you're
in though if some operation fails, which implies that the push above
is returning a reasonable result code, and whatever interface we give
for absolute navigation also has to return a reasonable result code,
which means it's not mere assignment.  I think we can allow

    @CWD = @SOMEDIR;

but that part of the interface probably needs to throw an exception
if it fails, since assignment must return @CWD.  Or maybe there's some
way to hack it, but that seems kind of hackish.

One interesting thought.  Since $" is turning into a property,
and since some directory schemes require varying delimiters, maybe
the $"-like property needs to be a list of delimiters, which you
repeat the last one of when you run out.  So Windows might use <: />,
while VMS might use <[ ] /> or whatever it was, I forget.  But this
would generalize to any array that needs varying delimiters in its
representation.

Larry

Reply via email to