Bug #67781 [Opn]: Use array() instead of square brackets

[email protected]
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=67781&edit=1

 ID:                 67781
 Updated by:         [email protected]
 Reported by:        [email protected]
 Summary:            Use array() instead of square brackets
 Status:             Open
 Type:               Bug
 Package:            PHP Language Specification
-PHP Version:        Irrelevant
+PHP Version:        PHP-5.6
 Block user comment: N
 Private report:     N

 New Comment:

I don't think we need to change the examples - [] is a legit feature of PHP and should not be avoided, unless it is confusing in a specific case. Not sure though which changes you ask for in array-creation-operator - could you elaborate?


Previous Comments:
------------------------------------------------------------------------
[2014-08-06 21:58:16] [email protected]

I'd say "the array literal syntax". It's a literal, not an operator.

------------------------------------------------------------------------
[2014-08-06 21:56:18] [email protected]

I am not a native speaker, but wouldn't "the xy operator" imply some sort of uniqueness in a general sense?
Especially as "the array operator []" is also "the subscript operator []".

I am thinking along the lines of "when using [] as the(an?) array operator". But that sounds less succinct and somehow less precise.

------------------------------------------------------------------------
[2014-08-05 17:10:39] [email protected]

There was disagreement here:

"Both notations are permitted, and unless we’re going to deprecate one of them, we should be able to use both. If that causes a significant problem, then IMHO the wrong spelling was chosen for the new/alternate notation."

------------------------------------------------------------------------
[2014-08-05 17:09:56] [email protected]

Description:
------------
https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#array-creation-operator

It might be better to say that "array(..)" is the 'array creation operator' and mostly use "array(..)" instead of "[..]" in examples. Most existing PHP code uses "array(..)" way more than "[..]" (because "[..]" was added very recently), and I think using "array(..)" as the 'array creation operator' helps disambiguate it from the subscript operator ("[]"). 



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67781&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.