BEGIN trait_mod:<is>(&any, :tighter(&infix:<*>));

comes to mind, but that doesn't seem to do the trick.

> On 22 Jun 2020, at 21:11, Tobias Boege <t...@taboege.de> wrote:
> 
> On Mon, 22 Jun 2020, Joseph Brenner wrote:
>> Patrick R. Michaud <pmich...@pobox.com> wrote:
>> 
>>> The "any" function is just like any other function taking an arbitrary list
>>> of arguments (including user-defined functions).  As such it parses with
>>> lower precedence than comparison operators -- so "eq" binds more tightly
>>> than "any".
>> 
>> Thanks, makes sense.
>> 
>>> I'm not exactly sure what sort of warning should go here, or how it'd be
>>> detected.
>> 
>> Yes, exactly.  From one point of view it's working as designed-- to me
>> it felt pretty weird, though.
>> 
>> Speculating wildly:  could there be a need for a different type of
>> function with different precedence?
>> 
> 
> You can achieve this today by redefining &any to be a prefix operator
> and provide it with tight enough precedence. In this example, I pick
> infix multiplication as the argument stopper, which is in particular
> tighter than the relevant eq operator; your mileage may vary:
> 
>  sub old-any (|c) { CORE::{'&any'}.(|c) }
> 
>  multi prefix:<any> (|c) is tighter(&infix:<*>) {
>      old-any |c
>  }
> 
>  say so any <a b c> eq any <c d>;            # True (fixed)
>  say so old-any(<a b c>) eq old-any(<c d>);  # True
>  say so old-any <a b c>  eq old-any <c d>;   # False
> 
> Now I'd be interested to see how someone would turn this into a
> frugal-sub declarator or an `is frugal` trait.
> 
> Regards,
> Tobias
> 
> -- 
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk

Reply via email to