Luke Palmer wrote:
These things are methods, and I'm not sure why we've crammed them into
smart match. Things like :M have nothing to do with matching. What
would it mean if smart match returned false?  "This file has not been
modified ever"?  :e has a bit more merit for a smart match, but the
operation has little to do with the concept of a string or the pair e
=> 1.

Also, I found the following line from S03 to be jolting:

   Any       Pair      test object             .STATUS(X) (Str,IO do filetest)

It struck me as a rather specific application for such a generic data type.

I'm inclined to say that the best solution for filetests is to throw
out our dwimmery altogether.  Back in Perl 4 days, using "stat"
explicitly was awkward, because you had to use it as a list and
memorize the positions of all the returns.  -s $file beats the heck
out of (stat $file)[7], for sure.  It also had the benefit that shell
people would instantly recognize what's going on.

However, now we have stat($file).size.  With that, every programmer
will recognize what's going on, not just people with shell background.
 And I don't think even people with a shell background will know what
($file ~~ :s) means (their guess could be right, but they'd have to
look it up to confirm, and they would never think to *write* such a

I can never remember whether mtime is -m or -M anyway...

Let's get rid of all the filetest magic, in favor of using stat explicitly.

I tend to agree that the magic should go away.  However, I already
miss the filetest operators.  Given the way that prefix operators
work, wasn't it already possible to say something like the following?

   given $handle {
       when .'-r' & .'-w' & .'-x' { ... }
       when !.'-w' | !.'-x' { ... }
       when * { ... }

   sort { $^a.'-M' <=> $^b.'-M' }, @files
   sort { .'-M' }, @files

What does pair notation buy us that quoted-postfix notation doesn't
already cover?

Jonathan "Dataweaver" Lang

Reply via email to