Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2013-01-28 Thread Ferenc Kovacs
2012.04.20. 8:08, Stas Malyshev smalys...@sugarcrm.com ezt írta:

 Hi!

  I can't estimate the amount of breakage, but what about using underscore
  (literal _) without quotation marks?

 This one is taken. See: http://us2.php.net/_

 --
 Stanislav Malyshev, Software Architect
 SugarCRM: http://www.sugarcrm.com/
 (408)454-6900 ext. 227

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


Hi,

what is the status of the rfc?
were there any reasons why you didn't called for votes?
Personally I would prefer named parameters also, and I think that we are
too close to the 5.5 feature freeze, but somebody asked why did the
progress stopped and I don't think that there were any showstopper issues.


Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2013-01-28 Thread Stas Malyshev
Hi!

 what is the status of the rfc?
 were there any reasons why you didn't called for votes?
 Personally I would prefer named parameters also, and I think that we are
 too close to the 5.5 feature freeze, but somebody asked why did the
 progress stopped and I don't think that there were any showstopper issues.

There are some issues with making internal functions compatible with
this and fixing all the tests, and I didn't have enough time to get
through it yet. I hope to get back to it in the near future, but
probably not in time for 5.5 if its schedule stays as it is now. The
concept is basically done but there are all kinds of cleanups to be done
and tests to be fixed and so on and it takes time, unfortunately.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-20 Thread Florian Anderiasch
On 04/18/2012 11:04 PM, Stas Malyshev wrote:
 Hi!
 
 default is already a reserved keyword. It's used in switch
 constructs. So it is safe to use :)
 
 Ah, silly me, indeed it is. Then I guess it doesn't hurt to add it as an
 option. Will do.

I can't estimate the amount of breakage, but what about using underscore
(literal _) without quotation marks?

In functional languages it's sometimes the default match in pattern
matching, that's at least a loose conversion and I hope not many people
would do
define(_, whatever) in their code.

The question now is, if create_query(a, _, _, _, true) really looks
better...

Greetings,
Florian

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-20 Thread Stas Malyshev
Hi!

 I can't estimate the amount of breakage, but what about using underscore
 (literal _) without quotation marks?

This one is taken. See: http://us2.php.net/_

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-19 Thread Patrick ALLAERT
2012/4/18 Matthew Weier O'Phinney weierophin...@php.net:
 My one comment, which others have raised, is readability of multiple
 commas -- TBH, at first glance it has the appearance of a mistake. I
 think those suggesting a keyword such as default make a good point in
 this regard -- it makes it 100% clear that you want the default value
 for the argument in that position. This also presents an improvement
 over current usage, as you're not hard-coding values in your function
 calls themselves -- particularly as the defaults could change in future
 refactors.

I think we should only support optional parameters using the default
keyword as it would probably make things more consistent and less
error prone:

function foo( $bar = bar, $foo = foo, $baz = baz ) { ... }

foo(,,, myBaz); // Thinking changing the value of $baz, but there's
one too much , and PHP won't complain because of too many arguments
used!

Additionally, we might also want to think about
call_user_func()/call_user_func_array().

If for the former it could work with:

call_user_func( foo, , , myBaz );

What about the latter?

call_user_func_array( foo, [2 = myBaz] ); // ? Evaluating the
element at index 0 would cause a notice, but would result in a NULL,
so I would say that NULL is to be used as first parameter.

I have no clue on how to correctly support skipped default values in
that case since there is a big difference in supporting the default
keyword inside the method call vs. as an element of an array.
Ideas are welcome!

Last but not least: if skipping optional parameters is implemented,
should we consider the support of default values on the leftmost side
of functions?

function foo( $bar = bar, $baz ) { ... }

It could make sense that $bar followed by $baz is semantically better
than the opposite for technical reason, and this could be called
using:

foo( default, baz)
or:
foo(, baz)

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-19 Thread Matthew Weier O'Phinney
On 2012-04-19, Patrick ALLAERT patrickalla...@php.net wrote:
 2012/4/18 Matthew Weier O'Phinney weierophin...@php.net :
  My one comment, which others have raised, is readability of multiple
  commas -- TBH, at first glance it has the appearance of a mistake. I
  think those suggesting a keyword such as default make a good point in
  this regard -- it makes it 100% clear that you want the default value
  for the argument in that position. This also presents an improvement
  over current usage, as you're not hard-coding values in your function
  calls themselves -- particularly as the defaults could change in future
  refactors.

 I think we should only support optional parameters using the default
 keyword as it would probably make things more consistent and less
 error prone:

 function foo( $bar = bar, $foo = foo, $baz = baz ) { ... }

 foo(,,, myBaz); // Thinking changing the value of $baz, but there's
 one too much , and PHP won't complain because of too many arguments
 used!

 Additionally, we might also want to think about
 call_user_func()/call_user_func_array().

 If for the former it could work with:

 call_user_func( foo, , , myBaz );

 What about the latter?

 call_user_func_array( foo, [2 = myBaz] ); // ? Evaluating the
 element at index 0 would cause a notice, but would result in a NULL,
 so I would say that NULL is to be used as first parameter.

I actually would argue you shouldn't skip parameters when using
call_user_func(); even with call_user_func_array(), I'd argue that named
parameters is the only way I'd want to allow skipping parameters.

The reason I argue this is because when dynamically calling a function,
you typically don't actually know exactly what the function/method is --
and thus making any assumptions about the signature other than required
parameters is simply begging for problems.

snip

 Last but not least: if skipping optional parameters is implemented,
 should we consider the support of default values on the leftmost side
 of functions?

 function foo( $bar = bar, $baz ) { ... }

 It could make sense that $bar followed by $baz is semantically better
 than the opposite for technical reason, and this could be called
 using:

 foo( default, baz)
 or:
 foo(, baz)

I'd argue no -- as required arguments should always have precedence over
optional ones in the signature when it comes to position.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-18 Thread Stas Malyshev
Hi!

 My one comment, which others have raised, is readability of multiple
 commas -- TBH, at first glance it has the appearance of a mistake. I
 think those suggesting a keyword such as default make a good point in
 this regard -- it makes it 100% clear that you want the default value

I wouldn't mind default but that means another keyword which means
another disruption (default would be pretty common method name, etc.)

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-18 Thread Nikita Popov
On Wed, Apr 18, 2012 at 10:24 PM, Stas Malyshev smalys...@sugarcrm.com wrote:
 Hi!

 My one comment, which others have raised, is readability of multiple
 commas -- TBH, at first glance it has the appearance of a mistake. I
 think those suggesting a keyword such as default make a good point in
 this regard -- it makes it 100% clear that you want the default value

 I wouldn't mind default but that means another keyword which means
 another disruption (default would be pretty common method name, etc.)
default is already a reserved keyword. It's used in switch
constructs. So it is safe to use :)

Nikita

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



Re: [PHP-DEV] Re: [RFC] skipping optional parameters

2012-04-18 Thread Stas Malyshev
Hi!

 default is already a reserved keyword. It's used in switch
 constructs. So it is safe to use :)

Ah, silly me, indeed it is. Then I guess it doesn't hurt to add it as an
option. Will do.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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