With perl v5.38.0 I wrote a code similar to:
perl -E 'sub foo ($x, $y //= 42, $z) {} foo(1, undef, 3)'
and got the error:
Mandatory parameter follows optional parameter at -e line 1, near "$z) "
So //= and ||= mark a parameter as optional, but optional parameters must follow mandatory ones. Outside of signatures these operators check a value of a variable. A mandatory parameter can have undef or false value. If it is feasible, maybe these operators could be applied to mandatory parameters as well.
--
Ivan Vorontsov <ivrntsv@yandex.ru>
perl -E 'sub foo ($x, $y //= 42, $z) {} foo(1, undef, 3)'
and got the error:
Mandatory parameter follows optional parameter at -e line 1, near "$z) "
So //= and ||= mark a parameter as optional, but optional parameters must follow mandatory ones. Outside of signatures these operators check a value of a variable. A mandatory parameter can have undef or false value. If it is feasible, maybe these operators could be applied to mandatory parameters as well.
--
Ivan Vorontsov <ivrntsv@yandex.ru>