old-design-docs icon indicating copy to clipboard operation
old-design-docs copied to clipboard

Smatchmatch against Pair not smart enough?

Open Mouq opened this issue 11 years ago • 1 comments

Currently S03 says about smartmatching against pairs: Any Pair test object attribute ?."{X.key}" === ?X.value (e.g. filetests) The primary value of this is for things like $file-path ~~ :e, which tests for the existence of a file, and $file-path ~~ :!e, which tests for the non-existence of a file.

It seems strange that Perl 6 forces a boolean comparison to the value. Wouldn't it be more consistent for the rule to be: Any Pair test object attribute ."{X.key}"() ~~ X.value

IRC conversation here: http://irclog.perlgeek.de/perl6/2014-04-27#i_8644524

Mouq avatar Apr 27 '14 16:04 Mouq

Note that $anything ~~ True is True, so your proposal would imply :!e ~~ :e, which isn't very intuitive. On the flip side, $anything ~ False is false, so $anything ~~ :!e would always return False.

IMHO the right thing to do is to abolish the ~~ :e notation for file testing; methods work well enough.

moritz avatar Apr 28 '14 07:04 moritz