On Fri, Sep 29, 2017 at 1:06 AM, Brandon Allbery <allber...@gmail.com> wrote:
> On Fri, Sep 29, 2017 at 12:59 AM, ToddAndMargo <toddandma...@zoho.com> > wrote: > >> On 09/28/2017 09:53 PM, ToddAndMargo wrote: >> >>> On 09/28/2017 09:45 PM, Brandon Allbery wrote: >>> >>>> IO::Path's .f method. (Or .e to not require it to be a file, etc. as >>>> usual.) >>>> >>>> pyanfar Z$ 6 '".profile".IO.f.say' >>>> True >>>> >>> >>> How do I get this to give me a "False" instead of crashing >>> and wagging the finger at me? >>> >>> $ perl6 -e 'say "eraseme.txt".IO.f;' >>> True >>> >>> $ perl6 -e 'say "erasxeme.txt".IO.f;' >>> Failed to find '/home/linuxutil/erasxeme.txt' while trying to do '.f' >>> in block <unit> at -e line 1 >>> >> >> method f >> >> Defined as: >> >> method f(--> Bool:D) >> >> Returns True if the invocant is a path that exists and is >> a file. The method will fail with X::IO::DoesNotExist if >> the path points to a non-existent filesystem entity. >> >> maybe it is suppose to crash? > > > This sounds broken, actually; I understand that a Failure treated as a > Bool prevented it from throwing, so it should have simply returned False. > > Checking it for .defined *does* prevent throwing. Still seems like a bug. > Apparently not a bug, just unfortunate. You have to explicitly coerce it to Bool to keep it from throwing. pyanfar Z$ 6 '".profileX".IO.f.Bool.say' False (And, Norman? It produces a Failure, not a hard exception. You can introspect Failures to keep them from getting thrown.) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net