Hi,

Somehow the current file test syntax, 'filename' ~~ :e, looks like a not
well-though-out translation of Perl 5's syntax, -e 'filename'.

Apart from totally feeling wrong to me, there are a few points I can put
my finger on:

1) $file ~~ :s returns a number, although smartmatching usually returns
a Bool
2) As currently designed, $str ~~ :e will always be True. That's because
'$x ~~ $y' where $y is Pair is defined as $x."$y.key()" ~~ $y.value. :e
is short for  :e(Bool::True), and smart-matching against True is always
True. D'oh. There might be a way to fix that, but that fact that nobody
noticed that so far only strengthens my opinion that this is not very
well thought-out so far.
3) I haven't look too closely at the list of proposed Perl 6 file test
operators, but Perl 5 has 29 of them. The idea of having 29 single
letter methods in class Str doesn't make me all that happy.

So I collected other ideas, both in my brain and in #perl6. Some of them
are:

$str.f.exists           # Str.f returns an "interpret this object
$str.f.size             # as a file name" object

$str.File.e             # same, different names

$str.stat.exists        # again

stat($str, :e)          # let multi dispatch handle it for us

So, let the bikeshedding begin!

Cheers,
Moritz

Reply via email to