I just read through https://github.com/rakudo/rakudo/issues/4878 and I had
a thought.

It's like the "where" clause has its own signature-like list of types
it will accept. When the where clause uses the default topic "$_" then that
topic has no constraint, and MAIN can probe if "--dir=something" should be
interpreted as a flag *Bool::True* or if it should be the string
*"something"*. When the "where" clause has only $dir in the body, the
optimizer can specialize it to only take Str, and then MAIN doesn't need to
probe the *Bool::True *case.

Haven't looked at the source, I'm guessing.

-y


On Sat, Apr 16, 2022 at 11:49 AM Luca Ferrari <fluca1...@gmail.com> wrote:

> On Fri, Apr 15, 2022 at 4:15 PM yary <not....@gmail.com> wrote:
> >
> > Here's how I ended up handling input arg validation, with meaningful
> error messages, as part of a Perl Weekly Challenge a couple years ago. It
> looks almost the same as Luca's original, except mine uses "die" instead of
> "warn", which means it won't attempt to continue once it encounters a bad
> arg.
>
> Interesting, but I used `warn` because I want to display all things
> that are not correct at once. In the test case I submitted there is no
> great difference in using warn instead of die, since the program
> should stop in any case, but if you have a bunch of named arguments I
> would like to see all `warn` messages at once, so I have a chance to
> fix all my invocation line at once.
>
> > I'm starting to think Luca's found a regression, since using the
> explicit variable name instead of the topic fixes the issue. That seems
> wrong.
>
> I don't know, in the beginning I thought there was a problem with the
> language specifcation, I mean, something has changed in the `wherre`
> and topic usage. However, hoping to improve our knowledge or the
> implementation, I've submitted an issue here
> <https://github.com/rakudo/rakudo/issues/4878>.
>
> Thanks,
> Luca
>

Reply via email to