rfc:any_all_on_iterable_straw_poll_namespace
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:any_all_on_iterable_straw_poll_namespace [2021/01/06 01:07] – tandre | rfc:any_all_on_iterable_straw_poll_namespace [2021/02/03 00:26] – close vote tandre | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Straw poll: Using namespaces for *any() and *all() on iterables ====== | ====== Straw poll: Using namespaces for *any() and *all() on iterables ====== | ||
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2021-01-05 | * Date: 2021-01-05 | ||
* Author: Tyson Andre, tandre@php.net | * Author: Tyson Andre, tandre@php.net | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 22: | Line 22: | ||
- I plan to propose additional internal functions for working with iterables if this succeeds, and would want to be sure this is the best name choice going forwards. | - I plan to propose additional internal functions for working with iterables if this succeeds, and would want to be sure this is the best name choice going forwards. | ||
- Additionally, | - Additionally, | ||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | ==== Arguments for voting again on namespaces ==== | ||
https:// | https:// | ||
Line 65: | Line 69: | ||
</ | </ | ||
- | ===== Discussion ===== | ||
- | ==== Choice of namespace | + | ==== Arguments for Spl\ ==== |
+ | |||
+ | This poll includes one of the naming options suggested by Levi Morrison and uses the suggested namespace for alternative options. | ||
< | < | ||
- | > I could start a second straw poll and wait for those results if you had a proposal for names in mind. | + | > I could start a second straw poll and wait for those results if you had a proposal for (a namespace) |
- | > `iterable\any_value`? | + | |
Simply `Spl\all_values`. I don't think there' | Simply `Spl\all_values`. I don't think there' | ||
Line 77: | Line 81: | ||
1) The SPL can disambiguate within itself. | 1) The SPL can disambiguate within itself. | ||
+ | |||
2) It _shouldn' | 2) It _shouldn' | ||
</ | </ | ||
Line 84: | Line 89: | ||
- Existing iterator/ | - Existing iterator/ | ||
- Existing classes are named SplObjectStorage, | - Existing classes are named SplObjectStorage, | ||
- | - It is less prone to conflicts than '' | + | - It is less prone to conflicts than '' |
- | - This can be reused for new classes/ | + | - The '' |
- | ==== Future extension ==== | + | https:// |
- | It is possibly that functionality to check if any/all keys satisfy a predicate, or any/all combinations of entries add a predicate. | + | < |
- | If this gets added, there are two possibilities | + | From Levi Morrison: |
- | - Add '' | + | I want to make a case for `Spl`. Aside from autoloading |
- | - Add flags to the ''*any()'' | + | ought to be in core but since " |
+ | functions it's kind of stuck), the SPL is mostly data structures and | ||
+ | iterator related functionality. It makes perfect sense to me that | ||
+ | iterator related behavior | ||
+ | should be included in the SPL. The `Spl` namespace is short, and its | ||
+ | brevity doesn't lose any meaning because the SPL has been around in | ||
+ | core since PHP 5.3 (I think?). | ||
- | There' | + | ... |
+ | |||
+ | One of the arguments against using the SPL is that much of its | ||
+ | existing design is... well, weird and sub-optimal in many cases. At | ||
+ | least a few people recommend against using SPL data structures and | ||
+ | iterators because of this. However, I think the `Spl` namespace can | ||
+ | separate these well enough. | ||
+ | </ | ||
+ | |||
+ | ==== Arguments | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | < | ||
+ | FWIW as iterables and the likes relate to engine features, the PHP | ||
+ | namespace policy RFC would have considered them ideal candidates for | ||
+ | \PHP\SubNS rather than \Ext\SubNS | ||
+ | |||
+ | Mark Randall | ||
+ | </ | ||
+ | |||
+ | From Nikita Popov: https:// | ||
+ | |||
+ | < | ||
+ | Using just the SPL namespace (that is, SPL\any) makes the SPL namespace a | ||
+ | dumping ground for everything, as you said. Once you introduce an | ||
+ | additional meaningful namespace in the form of SPL\iterable\any, | ||
+ | better off either dropping the SPL part and arriving at iterable\any, | ||
+ | replacing SPL with something more sensible and arriving at PHP\iterable\any. | ||
+ | </ | ||
+ | |||
+ | ==== Arguments for/against iterable\ in namespace ==== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | < | ||
+ | I' | ||
+ | suggestion to namespace them under Spl makes sense. This functionality has | ||
+ | fairly little to do with the SPL as it is now and to be honest, by now | ||
+ | there is quite a bit of ... stigma associated with functionality that | ||
+ | resides in SPL. | ||
+ | |||
+ | I would suggest using iterable\any and iterable\all as the names if we want | ||
+ | to go down this route. iterable_any and iterable_all were the by far most | ||
+ | popular choices on the previous poll, and these are just the namespaced | ||
+ | variants thereof. | ||
+ | |||
+ | Regards, | ||
+ | Nikita | ||
+ | </ | ||
+ | |||
+ | From https:// | ||
+ | |||
+ | I've also realized that '' | ||
+ | but still include | ||
+ | |||
+ | <code php> | ||
+ | php > namespace iterable { function my_any(...$args) {echo "in my_any() polyfill\n"; | ||
+ | php > \iterable\my_any(); | ||
+ | in my_any() polyfill | ||
+ | php > namespace X { use iterable\my_any; | ||
+ | in my_any() polyfill | ||
+ | php > namespace { iterable\my_any(); | ||
+ | in my_any() polyfill | ||
+ | |||
+ | |||
+ | |||
+ | php > namespace W { echo iterable:: | ||
+ | W\iterable | ||
+ | php > namespace X { use iterable; } | ||
+ | |||
+ | Fatal error: Cannot use iterable | ||
+ | php > namespace X { use PHP\iterable; | ||
+ | |||
+ | Fatal error: Cannot use PHP\iterable | ||
+ | |||
+ | php > namespace X { use iterable as iter; iter\my_any(); } | ||
+ | in my_any() polyfill | ||
+ | </ | ||
===== Vote ===== | ===== Vote ===== | ||
+ | |||
+ | Voting started on 2021-01-19 and ended on 2021-02-02 | ||
This vote will influence the name choice for the RFC https:// | This vote will influence the name choice for the RFC https:// | ||
Line 103: | Line 197: | ||
This is a ranked-choice poll (following [[https:// | This is a ranked-choice poll (following [[https:// | ||
- | <doodle title=" | + | With STV you SHOULD rank all the choices in order (but are not required to). Don't pick the same option more than once, as that invalidates your vote. |
+ | |||
+ | **Clicking on vote will only submit your vote for the above question, not for all of them.** You may want to write down your choices to avoid losing track of them. To quickly return to the vote section, click on " | ||
+ | |||
+ | * no namespace: iterable_any()/ | ||
+ | * iter\ (conflicts with [[https:// | ||
+ | * iterable\ (see [[# | ||
+ | * PHP\ (see [[# | ||
+ | * PHP\Spl\ (see [[# | ||
+ | * PHP\iter\ (see [[# | ||
+ | * PHP\iterable\ (see [[# | ||
+ | * Ext\Spl, as one interpretation of https:// | ||
+ | * Spl\ (see [[# | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | |||
+ | |||
+ | First choice: | ||
+ | <doodle title=" | ||
* iterable_any() and iterable_all() | * iterable_any() and iterable_all() | ||
- | | + | |
- | * Spl\any_value() and Spl\all_values() | + | * iterable\ |
- | * Spl\iterable_any() and Spl\iterable_all() | + | * PHP\ |
+ | * PHP\Spl\ | ||
+ | | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | | ||
+ | * Spl\iter\ | ||
+ | | ||
</ | </ | ||
- | <doodle title=" | + | Second choice: |
+ | |||
+ | <doodle title=" | ||
* iterable_any() and iterable_all() | * iterable_any() and iterable_all() | ||
- | | + | |
- | * Spl\any_value() and Spl\all_values() | + | * iterable\ |
- | * Spl\iterable_any() and Spl\iterable_all() | + | * PHP\ |
+ | * PHP\Spl\ | ||
+ | | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | | ||
+ | * Spl\iter\ | ||
+ | | ||
</ | </ | ||
- | <doodle title=" | + | Third choice: |
+ | |||
+ | <doodle title=" | ||
* iterable_any() and iterable_all() | * iterable_any() and iterable_all() | ||
- | | + | |
- | * Spl\any_value() and Spl\all_values() | + | * iterable\ |
- | * Spl\iterable_any() and Spl\iterable_all() | + | * PHP\ |
+ | * PHP\Spl\ | ||
+ | | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | | ||
+ | * Spl\iter\ | ||
+ | | ||
</ | </ | ||
+ | Fourth choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | |||
+ | Fifth choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | |||
+ | Sixth choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | |||
+ | Seventh choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | |||
+ | Eighth choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | |||
+ | Ninth choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | |||
+ | Tenth choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
+ | Eleventh choice: | ||
+ | |||
+ | <doodle title=" | ||
+ | * iterable_any() and iterable_all() | ||
+ | * iter\ | ||
+ | * iterable\ | ||
+ | * PHP\ | ||
+ | * PHP\Spl\ | ||
+ | * PHP\iter\ | ||
+ | * PHP\iterable\ | ||
+ | * Ext\Spl\ | ||
+ | * Spl\ | ||
+ | * Spl\iter\ | ||
+ | * Spl\iterable\ | ||
+ | </ | ||
===== What the functions do ===== | ===== What the functions do ===== | ||
Line 149: | Line 412: | ||
}; | }; | ||
</ | </ | ||
+ | |||
+ | ===== Future extension of any/all ===== | ||
+ | |||
+ | It is possible that functionality to check if any/all keys satisfy a predicate, or any/all combinations of entries add a predicate. | ||
+ | If this gets added, there are two possibilities | ||
+ | |||
+ | - Add '' | ||
+ | - Add flags to the '' | ||
+ | |||
+ | There' | ||
+ | |||
===== Rejected Choices ===== | ===== Rejected Choices ===== | ||
Line 179: | Line 453: | ||
- https:// | - https:// | ||
+ | ===== Changelog ===== | ||
+ | |||
+ | 0.2: Switch to a vote on multiple namespaces |
rfc/any_all_on_iterable_straw_poll_namespace.txt · Last modified: 2021/02/03 00:30 by tandre