rfc:any_all_on_iterable_straw_poll

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:any_all_on_iterable_straw_poll [2020/12/19 20:09] – created tandrerfc:any_all_on_iterable_straw_poll [2020/12/29 00:07] (current) tandre
Line 1: Line 1:
-====== Straw poll: Naming for any() and all() on iterables ====== +====== Straw poll: Naming for *any() and *all() on iterables ====== 
-  * Version: 0.1+  * Version: 0.2
   * Date: 2020-12-19   * Date: 2020-12-19
   * Author: Tyson Andre, tandre@php.net   * Author: Tyson Andre, tandre@php.net
-  * Status: Draft+  * Status: Complete
   * First Published at: http://wiki.php.net/rfc/any_all_on_iterable_straw_poll   * First Published at: http://wiki.php.net/rfc/any_all_on_iterable_straw_poll
  
Line 46: Line 46:
 ===== Vote ===== ===== Vote =====
  
 +This vote will influence the name choice for the RFC https://wiki.php.net/rfc/any_all_on_iterable
  
-<doodle title="Straw poll: Preferred choice of naming pattern" auth="tandre" voteType="multi" closed="false">+Voting starts on 2020-12-19 and will close on 2020-12-26. 
 + 
 +<doodle title="Straw poll: Preferred choice of naming pattern" auth="tandre" voteType="multi" closed="true">
    * any() and all()    * any() and all()
    * iter_any() and iter_all()    * iter_any() and iter_all()
    * iterable_any() and iterable_all()    * iterable_any() and iterable_all()
 +   * Opposed to names
    * Opposed to adding this functionality    * Opposed to adding this functionality
 </doodle> </doodle>
Line 86: Line 90:
 Using static methods instead of global functions was not considered since it would be impractical to polyfill new functions that get added in future php versions in a standard way. (e.g. ''IterUtils::all()'' Using static methods instead of global functions was not considered since it would be impractical to polyfill new functions that get added in future php versions in a standard way. (e.g. ''IterUtils::all()''
  
-Changing other iterable functions such as ''iterable_apply()'' to accept iterator instead of Traversable is out of the scope of the RFC or poll.+==== Existing iterator methods ==== 
 + 
 +The prefix ''iterator_'' was not considered. In PHP, [[https://www.php.net/manual/en/class.iterator|Iterator]] and [[https://www.php.net/manual/en/class.iteratoraggregate.php|IteratorAggregate]] already exist, and classes that implement Traversable must implement either Iterator or IteratorAggregate. The name ''iterator_'' would be misleading for functions that also accept arrays. 
 + 
 +  * I don't want to be in a situation where there are a large number of ''iterator_*()'' functions, where some accept ''Traversable'' and some accept ''iterable''
 +  * I also don't want to be in a situation where some have $iterator as a named argument (since PHP 8.0, e.g. ''iterator_to_array()'') and others have $iterable. 
 +  * If I was choosing names from scratch, ''*foo(iterable $iterable, ...)'' would make more sense than ''iterator_foo(iterable $iterator, ...)'' 
 + 
 +Changing other iterator functions such as ''iterator_apply()'', ''iterator_count()'', and ''iterator_to_array()'' to accept iterator instead of Traversable(Iterator and IteratorAggregate) is out of the scope of the RFC or straw poll
 + 
 + 
 +  * My preference would be to add new ''iterable_apply()'', ''iterable_count()'', and ''iterable_to_array()'' functions instead of modifying the existing methods. This would be possible to polyfill, and it would be less likely that code developed for 8.1+ would pass arrays that would be rejected by php 8.0 and older.  
 +  * Any alternative RFCs to change the behaviors of ''iterator_apply()'', ''iterator_count()'', and ''iterator_to_array()'' can be done independently of adding ''*any()'' and ''*all()''.
  
 ===== References ===== ===== References =====
Line 93: Line 109:
   - https://github.com/php/php-src/pull/6053   - https://github.com/php/php-src/pull/6053
  
 +===== Changelog =====
 +
 +0.2: Document why ''iterator_'' was not considered as an option.
rfc/any_all_on_iterable_straw_poll.1608408578.txt.gz · Last modified: 2020/12/19 20:09 by tandre