rfc:shortsyntaxforarrays

Differences

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

Link to this comparison view

rfc:shortsyntaxforarrays [2008/05/30 14:16]
thezapper
rfc:shortsyntaxforarrays [2017/09/22 13:28]
Line 1: Line 1:
-====== Request for Comments: Short syntax for arrays ====== 
-  * Version: 0.5 
-  * Date: 2008-27-05 
-  * Author: Ryusuke Sekiyama <rsky0711 at gmail . com>, Sebastian Deutsch <sebastian.deutsch at 9elements . com> 
-  * Status: Under Discussion 
-  * First Published at: 2008-01-10 
-  * Votes (+24/-19):  
-    * Pro: Andrei Zmievski, Andi Gutmans, Alexey Zakhlestin, Brian Moon, Carl P. Corliss, Darius Jahandarie, Eric Coleman, Giedrius D, Kalle Sommer Nielsen, Larry Garfield, Max Antonov, Mike Ford, Pierre Joye, Rasmus Lerdorf, Ryusuke Sekiyama, Sam Barrow, Stanislav Malyshev, Taylor Luk, Stefan Marr, Hans Ahlin, Karoly Negyesi, Edin Kadribasic, Guilherme Blanco, Jonathan-Bond Caron 
-    * Contra: Antony Dovgal, David Coallier, Derick Rethans, Geoffrey Sneddon, Hannes Magnusson, Jani Taskinen, Lokrain, Tomi Kaistila, David Zühlke, Felipe Pena, Lukas Kahwe Smith, Richard Quadling, Maciek Sokolewicz, Marcus Boerger, Philip Olson, Ilia Alshanetsky, David Soria Parra, Daniel Brown, Jochem Maas 
-  * Userland Votes (+1/0): 
-    * Pro: Sebastian Deutsch 
-    * Contra:  
- 
-This RFC will discuss an language enhancement for simple and easy array definition. 
- 
-===== Introduction ===== 
- 
-In some cases it is necessary that you have to pass function parameters as an array. 
-Especially when you work with nested arrays the php array function tends to make the code 
-looking ugly. If you take a look at other languages (Ruby, Python, Javascript) there is 
-a short syntax for arrays using square brackets. Maybe PHP should adopt this behaviour 
-to make code more readable and maintainable. 
- 
-Another solution would be to implement [[http://en.wikipedia.org/wiki/Keyword_argument|named parameters]]. 
- 
-===== Syntax ===== 
- 
-Ryusuke suggested two possibly syntaxes and also provides two patches for a solution: 
- 
-**Square bracket array shortcut - keys and values are separated by colons:** 
-<code php> 
-    $a = [1, 2, 3]; 
-    $b = ['foo': 'orange', 'bar': 'apple', 'baz': 'lemon']; 
-</code> 
- 
-**Square bracket array shortcut - keys and values are separated by double arrows:** 
-<code php> 
-    $a = [1, 2, 3]; 
-    $b = ['foo' => 'orange', 'bar' => 'apple', 'baz' => 'lemon']; 
-</code> 
- 
-===== Proposal and Patch ===== 
- 
-The first solution is more compact: http://www.opendogs.org/pub/php-5.3dev-080109-sbar.patch \\ 
-The second solution is more "The PHP Way": http://www.opendogs.org/pub/php-5.3dev-080109-sbar2.patch \\ 
- 
- 
-===== Pro / Contra ===== 
- 
-Pro and contra arguments that were derived from the list. 
- 
-==== Pro ==== 
- 
-  * Good for framework development when dealing with long parameterlists  
-  * Other web languages have similar syntax 
-  * Readable 
- 
-==== Contra ==== 
- 
-  * Yet another alias 
-  * Would take distinctness from [] 
-  * Not searchable through search engines 
-  * Unreadable 
- 
-===== Discussion on the List ===== 
-  - 2003-11-04 : [[http://markmail.org/message/rfolc6gxjmit6nes|Proposal: Array syntax]]   
-  - 2007-02-03 : [[http://markmail.org/message/67nff7mn4kqdbtfm|Syntactic improvement to array]] 
-  - 2008-01-08 : [[http://markmail.org/message/54sadarpmjdhsm3f|[RFC] Square brackets shortcut]] 
-  - 2008-01-11 : [[http://markmail.org/message/c4jwv7dl2uufxuxh|SUMMARY: Array syntax]] 
-  - 2008-05-21 : [[http://markmail.org/message/rsi4welftwou24p3|Short syntax for array literals]] 
  
rfc/shortsyntaxforarrays.txt · Last modified: 2017/09/22 13:28 (external edit)