On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik <jpola...@charter.net> wrote:
>
> I am trying to define '!' as the factorial operator. The following works
> in a .raku script file:
>
>    sub postfix:<!> ($n) is export {
>      when $n == 0 {return 1}
>      default {$n * ($n - 1)!}
>    }
>
> However when I tried to move this sub to a .rakumod file,
> it produces an error: Negation metaoperator not followed
> by valid infix.

That's because Raku isn't picking up your `sub`.

I don't know why. It works for me. (v2022.02)

Are you sure you're `use`ing it correctly and the `sub`
has the `is export`?

Can anyone else reproduce Joseph's problem?

> It turns out that this is a known issue, #3774

No, that's specific to the REPL.

The error message is the same; the common thing between
the two cases is that Raku is unaware the postfix has been
defined. The REPL problem is known. But the problem you're
sharing is unrelated to the REPL problem.

--
love, raiph

Reply via email to