From:

Date:

September 6, 2023 07:26Subject:

Re: //= and ||= in subroutine signaturesMessage ID:

31537f6b-6159-426e-89fa-7eb68e4d38a5@isolution.nlOn 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

- //= and ||= in subroutine signatures by Ivan Vorontsov
- Re: //= and ||= in subroutine signatures by Branislav ZahradnĂk
- Re: //= and ||= in subroutine signatures by Dave Mitchell
- Re: //= and ||= in subroutine signatures by Ivan Vorontsov
- Re: //= and ||= in subroutine signatures by Dave Mitchell
- Re: //= and ||= in subroutine signatures by Ivan Vorontsov
- Re: //= and ||= in subroutine signatures by Ivan Vorontsov
**Re: //= and ||= in subroutine signatures**by "Ruud H.G. van Tol" via perl5-porters- Re: //= and ||= in subroutine signatures by ASSI
- Re: //= and ||= in subroutine signatures by Ivan Vorontsov
- Re: //= and ||= in subroutine signatures by Dave Mitchell
- Re: //= and ||= in subroutine signatures by Ivan Vorontsov
- Re: //= and ||= in subroutine signatures by Paul "LeoNerd" Evans
- Re: //= and ||= in subroutine signatures by Ivan Vorontsov
- Re: //= and ||= in subroutine signatures by Ovid

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About