rfc:argument_unpacking
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:argument_unpacking [2013/09/30 12:48] – update implementation, mention string keys nikic | rfc:argument_unpacking [2014/01/11 12:12] – -> Implemented nikic | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2013-08-30 | * Date: 2013-08-30 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
- | * Proposed for: PHP 5.6 | + | |
* Patch: https:// | * Patch: https:// | ||
* Mailing list discussion: http:// | * Mailing list discussion: http:// | ||
Line 94: | Line 93: | ||
</ | </ | ||
- | By-reference passing will not work if the unpacked entity is a Traversable. Instead an '' | + | By-reference passing will not work if the unpacked entity is a Traversable. Instead an '' |
<code php> | <code php> | ||
test(...new ArrayIterator([1, | test(...new ArrayIterator([1, | ||
- | // Strict standards: Cannot pass by-reference argument 3 of test() by unpacking a Traversable, | + | // Warning: Cannot pass by-reference argument 3 of test() by unpacking a Traversable, |
</ | </ | ||
Line 108: | Line 107: | ||
==== String keys ==== | ==== String keys ==== | ||
- | In order to ensure forward-compatibility with [[rfc: | + | In order to ensure forward-compatibility with [[rfc: |
===== Backward Compatibility ===== | ===== Backward Compatibility ===== | ||
Line 214: | Line 213: | ||
} | } | ||
} | } | ||
+ | </ | ||
+ | |||
+ | ==== Normal arguments after unpacked arguments ==== | ||
+ | |||
+ | Some people also had doubts regarding the usefulness of allowing '' | ||
+ | |||
+ | One use-case for this pattern are the variants of '' | ||
+ | |||
+ | <code php> | ||
+ | array_udiff(...$arrays, | ||
+ | array_udiff_uassoc(...$arrays, | ||
+ | </ | ||
+ | |||
+ | While this kind of API was undoubtedly a bad choice in the first place, I see little reason not to support calls to them. | ||
+ | |||
+ | Another use case is appending one additional argument to a variadic argument list. For example, the following snippet adds an additional '' | ||
+ | |||
+ | <code php> | ||
+ | $this-> | ||
</ | </ | ||
Line 219: | Line 237: | ||
The patch for this features is available as a PR: https:// | The patch for this features is available as a PR: https:// | ||
+ | |||
+ | ===== Vote ===== | ||
+ | |||
+ | As this is a language change a two third majority is required. | ||
+ | |||
+ | Voting started 2013-12-21 and ended 2014-01-11. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Support in other languages ===== | ===== Support in other languages ===== |
rfc/argument_unpacking.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1