Perhaps you could create an error function that temporarily sets the
default error message (does perl 6 still have the $! variable?) and
returns false; so:

    subset Filename of Str where { $_ ~~ :f or error ( "No such file: '$_'" ) }

Of course, that's a rather narrowly-defined function, as it's intended
only for use in one situation - that is, where a boolean test is
likely to be used by the parser to determine whether or not Something
Bad needs to happen.  I can't think of any case other than custom
error messages for subsets where this would happen...

Personally, I'd prefer something more along the lines of:

    subset Filename of Str where { $_ ~~ :f; ERROR { "No such file: '$_'" } }

That is, have the parser look inside where blocks (or any other block
that might convert a falsehood to a failure) for an ERROR block that
is intended to be executed just as the error is about to be triggered.
 The primary purpose would be to supply a customized error message
(and for that reason, the return value should be a string that can be
used as $!); but other possibilities would exist.

-- 
Jonathan "Dataweaver" Lang

Reply via email to