in reply to Re^2: Implementing named infix operators with parser hook?
in thread Implementing named infix operators with parser hook?
Only just noticed this line of your comment:
I think it doesn't, since I need most operators already. :/
Not sure what you mean by it. Did you assume that using Sub::Infix takes over existing operators, so you can no longer use (for example) the | or / operators normally? Because that's not what it does. You can continue to use the existing Perl operators normally, with no slow down, but Sub::Infix will allow you to define additional operators like:
use Sub::Infix; BEGIN { *between = infix { my ($number, $range) = @_: $number >= $range->[0] and $number <= $range->[1]; }; } if ($value <<between>> [1,10]) { ...; }
The only limitation is that your infix operator can't be spelled just between. It needs to be |between|, /between/, or <<between>> (and depending on which you choose, you'll get different precedence).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Implementing named infix operators with parser hook?
by LanX (Saint) on Aug 17, 2018 at 12:50 UTC |