# [SPAM] Re:  Syntactic improvement to array

- Thread: https://externals.io/message/27851
- Original archive: https://news-web.php.net/php.internals/27851
- Started by Ford on 2007-02-06T14:08:13+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #27851 — Ford — 2007-02-06T14:08:13+00:00

URL: https://externals.io/message/27851#27851

> Ford, Mike wrote:
> > […]
> array() version actually quite UNreadable and I have
> difficulty picking out what the individual arrays are;
> conversely, the [] version I take in at a glance.
> 
> That is why you have coding standards.  Our doucment states that this
> should be written as: 
> 
> $a = array(
> 	1 => array('pears', 'apples'),
> 	2 => array('juice', 'oranges')
> );
> 
> I believe in either syntax, proper formatting of complex data
> can solve
> the readablity problems.

Solve, no.  Alleviate, yes.

Given the above, the layout tells me there's some kind of structure
going on, but I still have to actually *read* it to discover
that there are arrays involved (and where they start and end).

With this version:

  $a = [
 	 1 => ['pears', 'apples'],
 	 2 => ['juice', 'oranges']
	];

I can take one glance and tell there are nested arrays involved, and
what their scopes are -- I'd say my comprehension speed is at least
an order of magnitude faster!

*That* makes this syntax a no-brainer for me, personally ;-)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

---

## #27854 — Robert Cummings — 2007-02-06T14:41:34+00:00

URL: https://externals.io/message/27851#27854 · In reply to: #27851

> 
> > […]
> 
> Solve, no.  Alleviate, yes.
> 
> Given the above, the layout tells me there's some kind of structure
> going on, but I still have to actually *read* it to discover
> that there are arrays involved (and where they start and end).
> 
> With this version:
> 
>   $a = [
>  	 1 => ['pears', 'apples'],
>  	 2 => ['juice', 'oranges']
> 	];
> 
> I can take one glance and tell there are nested arrays involved, and
> what their scopes are -- I'd say my comprehension speed is at least
> an order of magnitude faster!
> 
> *That* makes this syntax a no-brainer for me, personally ;-)

Ummm, you still had to read it. One "glance" just so happens to involve
the brain grokking the content, just like reading.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

---

## #27855 — Alain Williams — 2007-02-06T14:46:53+00:00

URL: https://externals.io/message/27851#27855 · In reply to: #27854

> 
> > […]
> 
> Ummm, you still had to read it. One "glance" just so happens to involve
> the brain grokking the content, just like reading.

I must agree that the [] is easier/quicker to read than array(), but is it
really worth it ... too many syntaxes for the same thing ?

Anyway: it makes php look like perl -- and that would never do :-)

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h

---

## #27856 — Christian Schneider — 2007-02-06T15:16:28+00:00

URL: https://externals.io/message/27851#27856 · In reply to: #27855

Alain Williams wrote:
> Anyway: it makes php look like perl -- and that would never do :-)

Can we please stop that FUD? (even if it is meant as a joke)

... if at all then you might say it looks like Javascript, Python or
Ruby. Perl uses an ugly mix of () and [] to emulate multi-dimensional
arrays rather unlike the syntax proposed here.

Thanks,
- Chris

---

## #27857 — Alain Williams — 2007-02-06T15:19:25+00:00

URL: https://externals.io/message/27851#27857 · In reply to: #27856

> Alain Williams wrote:
> > […]
> 
> Can we please stop that FUD? (even if it is meant as a joke)

No: it was NOT a serious point. What is wrong with the occasional grin ?

> ... if at all then you might say it looks like Javascript, Python or
> Ruby. Perl uses an ugly mix of () and [] to emulate multi-dimensional
> arrays rather unlike the syntax proposed here.
> 
> Thanks,
> - Chris

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h
