At the moment the file test operators that I expect to return true or
false do, but the true is the filename. 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. :)
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 get the filename for each part:
foo foo foo
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?
pugs> ( "Talks" ~~ :r ).say
Talks
Bool::True
pugs> ( "Talks" ~~ :d ).say
Talks
Bool::True
pugs> "Talks".TEST(:s).say
*** No such method in class Str: &TEST
at <interactive> line 1, column 1-21
pugs> "Talks".:s
Internal error while running expression:
***
Unexpected ":s"
expecting ".", "\187", ">>", "=", operator name, qualified
identifier, variable name, "...", "--", "++", "i", array subscript,
hash subscript or code subscript at <interactive> line 1, column 9
pugs> "Talks".":d"
Internal error while running expression:
***
Unexpected "\":"
expecting ".", "\187", ">>", "=", operator name, qualified
identifier, variable name, "...", "--", "++", "i", array subscript,
hash subscript or code subscript at <interactive> line 1, column 9