Re: Skipping of defaulted parameters.

From: Date: Thu, 21 Oct 2010 08:11:38 +0000
Subject: Re: Skipping of defaulted parameters.
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-49947@lists.php.net to get a copy of this message
Option 4 would probably be the worse one to go for. Looking any number of languages that support defaults and you will see code like ... someFunction(param1,,,,,param7,,,,param11)
It does get ugly fast for large numbers of arguments... But any function with more than a handful of arguments is already asking for trouble... At that point you should be passing in a data structure / instance / array or something other than so many parameters.
The above example would have at least 10 arguments, so I'd also say it'd look bad never mind the syntax. Also a subtle thing: if your email reader doesn't use fixed width font, it's hard to appreciate the look of each approach in an actual code editor. And I'd say commas next to each other appear quite readable, self-sufficient in fixed-width font, not to mention self-explanatory. Using 'default' would raise more confusion, such as, is that valid: $foo = default; bar($foo); If it's made valid, i.e. if it acts as a constant, I suspect before long people will be assigning 'default' as yet another alternative to a false/null value, and we'll need yet another concept to resolve that. If it's not made valid, it'll be counter-intuitive as it looks exactly like a constant passed as an argument. Stan Vass

« previous php.internals (#49947) next »