Re: Re: Modify language grammar to allow trailing commas in function/method calls
| From: | Richard Quadling | Date: | Tue, 22 Jul 2008 14:33:18 +0000 |
| Subject: | Re: Re: Modify language grammar to allow trailing commas in function/method calls | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-39189@lists.php.net to get a copy of this message | ||
2008/7/22 Rodrigo Saboya <rodrigo.saboya@bolsademulher.com>
> Evan Priestley escreveu:
>
>> This was floated in 2003 but had weak advocation and didn't seem to come
>> to a decisive resolution:
>>
>>
>> http://marc.info/?l=php-internals&m=106685833011253&w=2
>>
>> Basically, the proposal is to modify the grammar to allow trailing commas
>> in function and method calls, so this becomes a parseable PHP construct:
>>
>> f(1, 2, 3,);
>>
>> This patch applies only to function and method calls; it does not apply to
>> function or method definitions. It also does not allow the degenerative case
>> of "f(,)".
>>
>> The real value of relaxing this rule is in nontrivial cases that span
>> across multiple lines:
>> sprintf(
>> 'long example pattern with %d conversions: %s',
>> $several,
>> $conversions
>> );
>>
>>
> You could just do this:
>
> sprintf(
> 'long example pattern with %d conversions: %s'
> ,$several
> ,$conversions
> );
>
> I really don't see a great benefit here, and as you pointed out it would
> make code written with trailing commas incompatible with previous versions
> of PHP.
>
> --
> Rodrigo Saboya
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Just thinking of other languages that allow you to skip params simply by
using commas. Whilst this isn't supported in PHP, allowing a trailing comma
and skipped parameters could look quite interesting!
foo(,,,,,,,);
I must admit, I get stung with this in JS when I'm building AJAX option sets
through Prototype for IE (I think like arrays in PHP which allow trailing
,), but I soon learned to do it properly.
I don't see this as a huge advantage.
Regards,
Richard Quadling.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"