On Tue, 5 Sep 2023 22:55:46 +0300 Ivan Vorontsov <ivrntsv@yandex.ru> wrote: > Wouldn't it be convenient to write as: > # $v, $w, $x are mandatory; $y, $z are optional > sub bar ($v, $w //= 42, $x, $y //= 1, $z = 2) { > } If you want $w to be mandatory, you can't put a defaulting expression on it. If you still want its value to be 42 if the caller *explicitly decided to pass undef*, that's that regular code inside the function is for. sub bar ($v, $w, $x, $y //= 1, $z = 2) { $w //= 42; ... } -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next