On Tue, Apr 12, 2022 at 10:15 AM Luca Ferrari <fluca1...@gmail.com> wrote: > > Hello all, > given this simple program: > > sub MAIN( Str :$dir where { .so && .IO.d // warn "Specify the > directory [$dir]" } ) { > say $dir; > } >
Shame on me: it works if I omit the topic and substitute it with the explicit variable, thus: sub MAIN( Str :$dir where { $dir.so && $dir.IO.d // warn "Specify the directory [$dir]" } ) { say $dir; } The only thing that I find in the documentation at <https://docs.raku.org/type/Signature#index-entry-where_clause> is: "The code in where clauses has some limitations: anything that produces side-effects (e.g., printing output, pulling from an iterator, or increasing a state variable) is not supported and may produce surprising results if used. Also, the code of the where clause may run more than once for a single typecheck in some implementations." Is there a better approach to spurting warning messages when a parameter is not correct (without dealing with USAGE() and friends)? Thanks, Luca