develooper Front page | perl.perl6.users | Postings from September 2017

can't adverb and infix

Thread Next
Luca Ferrari
September 19, 2017 07:45
can't adverb and infix
Message ID:
Hi all,
this will sound trivial, but the following piece of code that in my
mind should work does not:

$mode = 'csv' if ( ! $mode.defined || %available_modes{ $mode }:!exists );

and the compiler says:

You can't adverb &infix:<||>
at /home/luca/tmp/am/folken.p6:16
------> ined || %available_modes{ $mode }:existsā¸¸ );
    expecting any of:
        pair value

The following works (placing the adverb before the or):

$mode = 'csv' if ( %available_modes{ $mode }:!exists || ! $mode.defined );

but it seems to me the defined test is now useless.
However, what's the reason the adverb cannot be applied to infix
logical or begin a bool? What's the mnemonic for not failing into such
error idiom as my first implementation?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About