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

can't adverb and infix

Thread Next
From:
Luca Ferrari
Date:
September 19, 2017 07:45
Subject:
can't adverb and infix
Message ID:
CAKoxK+4ASS-L7Jw8nqgH8rBO3bP7BKoxuegL-fYp0+1msDEsRw@mail.gmail.com
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?

Thanks,
Luca

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About