On Fri, Sep 6, 2013 at 6:01 PM, Pascal Chevrel <pascal.chev...@free.fr> wrote:
> Le 06/09/2013 18:39, Nikita Popov a écrit :
>
>> Hi internals!
>>
>> I created an RFC and preliminary implementation for named parameters:
>>
>>      https://wiki.php.net/rfc/named_params
>>
>> The RFC and implementation are not yet complete. I mainly want to have
>> feedback on the idea in general and on the Open Questions (
>> https://wiki.php.net/rfc/named_params#open_questions) in particular.
>>
>> Thanks,
>> Nikita
>>
>
> Hi Nikita,
>
> I love it and I love that it also applies to internal functions!
> My preference for syntax would be this one:
>
> test($foo: "oof", $bar: "rab");

I agree that the : instead of => would make it more readable and avoid
confusion with array params in a fast/diagonal reading...
However I am a bit averse to using $ for the keys, meaning for newer
users this might become increasingly confusing:

function fn($value1 = 20, $value2 = 1, $value3 = 3)
{
  echo $value1 . $value2 . $value3;
}

$value1 = 20;
$value3 = 9;
fn($value1, $value3 => 4); // Quick read expected 2019; got 2014!

Hopefully this is a simple enough example to show the confusion that
might arise.

>
> Using the $ sign means that it doesn't class with reserved keywords and that
> is consistent with the use of the dollar sign in PHP when we define the
> functions. I prefer : to => because it is a tad shorter and I think a bit
> more readable.
>

Indeed it's needed to avoid the reserved keywords issue...
And I SINCERELY hope this RFC is accepted; but I am definitely worried
what the syntax should be in order to improve readability, keep
consistency within PHP, while avoiding confusion (mostly for new
users, but also for the fast code read we usually make on a daily
basis!)

Perhaps the test($foo: "oof", $bar: "rab"); would be a more in line of
what I think solves both issues (Niki, could you please add that one
to the RFC?)

> Thanks!
>
> Pascal
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Thanks

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to