On 2023-09-05 23:37, Ivan Vorontsov wrote: > [...] > f($x, $y = 1, $z = 2) # $y is optional parameter > f($x, $y //= 1, $z = 2) # $y is mandatory parameter > f($x, $y //= 1, $z ) # $y is mandatory parameter > f($x, $y //= 1 ) # $y is mandatory parameter > > Consider this example: > > f($v, $w //= 42, $x, $y //= 1, $z = 2) > > Here $v, $w, $x, $y are mandatory, $z is optional. But function can be > called with less arguments than number of mandatory parameters because > of $y. Mandatory is a strict condition, so if-or-when it gets called with less arguments than defined as the minimum, then that is an error, which is best caught at compile-time ("if") already. A run-time ("when") check is still needed, as f(@v) could turn out to be a violation. -- RuudThread Previous | Thread Next