Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76235 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32651 invoked from network); 28 Jul 2014 19:14:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2014 19:14:06 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:48384] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/80-29900-BF0A6D35 for ; Mon, 28 Jul 2014 15:14:05 -0400 Received: by mail-vc0-f170.google.com with SMTP id lf12so11918579vcb.29 for ; Mon, 28 Jul 2014 12:14:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=yGl/T45QWA/Sln2G5etAwJa9Zmeri61X07iH1IUHB2I=; b=H5TvWdkPkpEYdJJU5iUgd9q+EBL/ARZqWRbl41+31+wD3TVR5Q3vuDZvAsC/MGyxIs AohaIXEv3XFe1k3qEe3bFVTBru/XrLsRS6AvBGo6mt/pNscmImC4jT51XjLzg5Pokxex jPWKYiir8nLfWPmjYjDq9OECyuGwrTt+CX/usSEZfetJ2XNPVWqV6fby3+/HlRiWOoUE +68ttgvXKk7VCX3ByHq+VwIANGyO4mUQHrahZmAgQ/vYbh97O2eOvMo2M4ZR05N7uaPb bd9h0bDpVOJnK/auFGFIPeywgurd0chZqafuyHGqHytBpscbxaM925r/9bWM0I1R4ri2 wRAw== X-Gm-Message-State: ALoCoQlvUL8CE/3LywHGfFpeB1Md9hrRSzy2GiFPY3Sk8aVOoX1O/mMpZJ4oHynwnHQQ8fnu5iDcGjzWmyXPwY2UnkWgcz/6cBI1pfViFskSxMSebB+HLGtYiLCDkp6bb7jQyo6RSLye MIME-Version: 1.0 X-Received: by 10.52.148.2 with SMTP id to2mr40282914vdb.38.1406574853348; Mon, 28 Jul 2014 12:14:13 -0700 (PDT) Received: by 10.52.110.170 with HTTP; Mon, 28 Jul 2014 12:14:13 -0700 (PDT) In-Reply-To: <71A78449-A62C-400D-A01F-5668930A7BED@ajf.me> References: <71A78449-A62C-400D-A01F-5668930A7BED@ajf.me> Date: Mon, 28 Jul 2014 23:14:13 +0400 Message-ID: To: Andrea Faulds Cc: Derick Rethans , Nikita Popov , Julien Pauli , PHP Internals Content-Type: multipart/alternative; boundary=bcaec52d57197c1fdd04ff45babc Subject: Re: [PHP-DEV] Thoughts on C version supported for PHP-Next From: dmitry@zend.com (Dmitry Stogov) --bcaec52d57197c1fdd04ff45babc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think opinions about readability are subjective. The real problem, that it'll break compatibility with old uncommon compilers. I'm not sure if new MSVC versions support it, but the one I use - does not. Breaking something without a real reason is not a good move. Thanks. Dmitry. On Mon, Jul 28, 2014 at 6:19 PM, Andrea Faulds wrote: > > On 28 Jul 2014, at 15:00, Derick Rethans wrote: > > >> Well, we don=E2=80=99t need to allow all of C99. We can simply allow u= sing > >> features that are widely supported and actually useful. For example, > >> declarations between statements, > > > > I think that makes code a lot less readable, so I would not be in favou= r > > allowing this in our coding guidelines. > > Really? I=E2=80=99ve found that declaring everything in advance makes for > hard-to-read code. To take an example from code I=E2=80=99ve written (adm= ittedly > not C code - GML if anyone=E2=80=99s curious - but it might as well be), = the first > line of a function looked like this: > > var list, hashList, text, i, pluginname, pluginhash, realhash, url, > handle, filesize, progress, tempfile, tempdir, failed, lastContact, > isCached, env; > > Even broken onto multiple lines, declaring everything at once isn=E2=80= =99t nice. > For large functions (and some functions have to be large necessarily), > declaring everything at the start just means a long list of variables and= I > would argue impairs code readability. > > You should declare variables when and where you need them. If everything > is done at the top, you have to scroll up to check the type of a variable= . > It also means that now-unused variables are less obvious as the > declarations are far away from the usage, so you probably won=E2=80=99t s= pot that > it=E2=80=99s useless unless you look at your compiler warnings. > > Actually, a similar issue popped up in the code where that example was > from. The language it was written in had some unfortunate properties, one > of which was that variables not explicitly declared would instead be > treated as properties of the current object. Because all the variables we= re > declared at the start of the function, it was easy to miss the fact that > some variables being used had not actually been declared. Of course this > specific issue doesn=E2=80=99t exist in C, but it is an example of why ha= ving to > declare all your variables at the start of a function isn=E2=80=99t reall= y a good > thing. > > If nothing else, I think we should use C99=E2=80=99s ability to declare v= ariables > between statements. It makes it more likely mistakes will be spotted, eas= es > reading code, and as far as I am aware, is widely supported. > > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --bcaec52d57197c1fdd04ff45babc--