On Thu, Apr 12, 2007 at 01:52:50PM -0500, brian d foy wrote:
: At the moment the file test operators that I expect to return true or
: false do, but the true is the filename.

You've just dug up a pugsian fossil.

: I expected a boolean, for no
: other reason than Perl 6 has them so it might as well use them. The
: section on Smart Matching in S03 says that the ~~ doesn't have to
: return a boolean,  but aside from things liek :s, :M, and :A, what good
: would it be not to? I'm happy to update S16 with whatever the answer
: is. :)

The intent of moving from the

    -r -w -x $file
    
form to the

    $file ~~ :r & :w & :x

form was to get rid of the klunky, inflexible statbuffer propagation
mechanism, which (without an temp var) could only do "and" and not
"or", and didn't work well syntactically in "when" statements.  Plus
it forced the user to worry about statbuf caching, which probably just
ought to timeout automatically since it assumes we're the only person
accessing the filesystem, a bogus assumption in the face of any kind
of multiprocessing.

So the new filetests just return a simple value, generally Bool or Num.
To get a statbuf object you now use an explicit stat or lstat.  Such an
object should probably stringify to "Stat('filename')" or some such, so
that the filename "0" comes out "Stat('0')".

I will attempt to clarify S03, though my brain is still a little
fuzzy this week for a variety of unrelated reasons.

: Here's my code example that motivates this question. For a Llama6
: exercise with file test operators, I wanted to create a little table:
: 
:    for @files -> $file {
:       printf "%-70s  %s  %s  %s\n",
:          $file,
:          $file ~~ :r,
:          $file ~~ :w,
:          $file ~~ :x;      
:       }

I think I would now write that more like:

    for @files -> $file {
        given stat $file {
          printf "%-70s  %s  %s  %s\n", $file, .:r, .:w, .:x;      
        }
    }

: Which I wanted to work like this perl5 (not that I care if it's
: different, I just have to explain it to reader)
: 
:    #!/usr/bin/perl5
:    foreach ( glob( "*" ) )
:       {
:       printf "%30s %s %s %s\n", $_, -r, -w, -x
:       }
: 
: 
: With the Pugs 6.2.13 (r15868), only the ~~ form seems to work, but is
: that going to be any different than the other two forms?

The current pugs implementation is just translating to the old form
underneath, so it's not surprising it's a bit off.  That's the sort
of thing that happens when the language designer gives the language
implementor whiplash.  However, I rather suspect the interpersonal
metaphorical meaning was lost on the physicist/comic who decided that
the 3rd derivative of position should be called "jerk".  :)

Larry

Reply via email to