Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27861 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42519 invoked by uid 1010); 6 Feb 2007 16:09:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42504 invoked from network); 6 Feb 2007 16:09:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2007 16:09:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=robert@interjinn.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=robert@interjinn.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain interjinn.com from 66.11.173.122 cause and error) X-PHP-List-Original-Sender: robert@interjinn.com X-Host-Fingerprint: 66.11.173.122 unknown Linux 2.5 (sometimes 2.4) (4) Received: from [66.11.173.122] ([66.11.173.122:52895] helo=blobule.interjinn.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/83-18465-638A8C54 for ; Tue, 06 Feb 2007 11:09:26 -0500 Received: by blobule.interjinn.com (Postfix, from userid 2000) id F0D005ACF7D; Tue, 6 Feb 2007 11:09:25 -0500 (EST) To: "Ford, Mike" Cc: Brian Moon , internals@lists.php.net In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: InterJinn Date: Tue, 06 Feb 2007 11:09:24 -0500 Message-ID: <1170778165.9567.13.camel@blobule> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Subject: RE: [PHP-DEV] [SPAM] Re: [PHP-DEV] Syntactic improvement to array From: robert@interjinn.com (Robert Cummings) On Tue, 2007-02-06 at 15:41 +0000, Ford, Mike wrote: > On 06 February 2007 14:42, Robert Cummings wrote: > > > On Tue, 2007-02-06 at 14:08 +0000, Ford, Mike wrote: > > > On 05 February 2007 17:29, Brian Moon wrote: > > > > 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 ;-) > > > > Ummm, you still had to read it. One "glance" just so happens to > > involve the brain grokking the content, just like reading. > > No, I didn't have to read it. I had to look at it and see its shape, and I may or may not have grokked it, but I didn't read it. I still have no idea what's actually *in* the arrays, I just know there are arrays and how they're structured. My brain, virtually instantaneously, goes, "Oh, brackets, nested arrays, 2 short arrays nested in an enclosing outer one!". I don't class that as reading, just visual comprehension. > > With the long version, my thought process goes more like "Uh, oh, indentation, must be some structure here. Can't see any obvious syntactic markers, just a mush of characters, so better read it. 'array', uh, ok an array, what's in it? explicit index 1 is, oh, 'array' again, ok, so we've got nested arrays, presumably this line is a self-contained inner array? let's see, 'pears', 'apples', and, oh yes, a proper matching close parenthesis; next line similar, explicit index 2, 'juice', 'oranges' and a close parenthesis, yup and a proper closing parenthesis for the outer array; right, 2 short arrays nested in an outer enclosing one." See how I've actually had to read and process *every* *single* *word* *and* *character* on the page? See how much slower it was? Now, that's what I call reading. > > My brain may be weird and unusual in working this way, but it does so I've become accustomed to it! I know it's off the norm in other areas (I have no problem keeping a dozen or so PINs in my head and reliably producing the right one without hesitation, and I generally remember personal ID, bank account and credit card numbers without even trying) so it wouldn't surprise me to find I'm way off the curve here too. Just permit me my little foibles, eh? > > Cheers! I know how much you want to feel special, but here's the definition of "read". Your description of how you interpret what you see falls into this definition: http://209.161.37.11/dictionary/read 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. | `------------------------------------------------------------'