Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76972 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52059 invoked from network); 30 Aug 2014 21:26:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2014 21:26:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=rewilliams@thesba.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rewilliams@thesba.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thesba.com designates 208.106.205.211 as permitted sender) X-PHP-List-Original-Sender: rewilliams@thesba.com X-Host-Fingerprint: 208.106.205.211 ntsexchedgea2.newtekemail.com Received: from [208.106.205.211] ([208.106.205.211:53017] helo=NTSEXCHEDGEA2.nts.phx1) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/10-50403-79142045 for ; Sat, 30 Aug 2014 17:26:48 -0400 Received: from NTSEXCHHUBA1.NTS.PHX1 (208.106.205.208) by NTSEXCHEDGEA2.newtekemail.com (208.106.205.211) with Microsoft SMTP Server (TLS) id 8.3.348.2; Sat, 30 Aug 2014 14:25:23 -0700 Received: from NTSEXCHA1CMB2.NTS.PHX1 ([fe80::3913:915c:3f89:aad]) by NTSEXCHHUBA1.NTS.PHX1 ([2002:d06a:cdd0::d06a:cdd0]) with mapi; Sat, 30 Aug 2014 14:26:43 -0700 To: PHP Developers Mailing List Date: Sat, 30 Aug 2014 14:26:43 -0700 Thread-Topic: [PHP-DEV] [RFC] Loosening heredoc/nowdoc scanner Thread-Index: Ac/EmRhG0u2Ib3RbSqSYn3m5zx6zFQ== Message-ID: References: <54020D72.3000403@googlemail.com> In-Reply-To: <54020D72.3000403@googlemail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Loosening heredoc/nowdoc scanner From: rewilliams@thesba.com (Robert Williams) If the syntax of heredocs/nowdocs is to be loosened, the biggest aspect I= =92d like to see addressed is indentation. I can certainly see how it would= be nice to loosen the restrictions around the post-closing-token newline t= o allow easier use in places like array definitions, but, I=92ve never run = into that problem myself. I have, however, been annoyed by the indentation = limitations, so much so that I could probably count with my fingers the num= ber of times that I=92ve used the construct in the couple million lines of = PHP I=92ve written =97 even though I *want* to use it about once a week. I = just find the side-effect on code formatting, when used in a container stru= cture (class, function, method, loop, whatever), to be more than I can hand= le. Look at this simple example from the docs to see what I mean: One of the key benefits of consistent indentation is that it allows very ra= pid visual navigation of code by nearly eliminating the need for reading un= til you=92ve zoned in on the right section of code. To illustrate this very= well, just try to visually identify the code structure in this old-school = BASIC code: That this restriction warrants italicized text inside a pink warning box in= the docs suggests both that lots of people bump into it and that it runs c= ounter to the expectations of the language. Now, perhaps I=92ve not felt constrained by the newline restriction simply = because I so rarely get to use the construct at all because of the indentat= ion restriction. That=92s actually probably the case. So that idea is impor= tant to address, but I think it=92s pointless to address without also addre= ssing indentation. What if we could do something like this: function foo() { $string =3D <<< THEEND This is the document text. Any whitespace appearing in a column that=92s before the starting token is automatically ignored for all lines. THEEND; A few particulars: * If the starting token appears immediately adjacent to the <<< sequence, t= hen parsing is done according to existing rules (perhaps with the changes i= n the RFC). This both maintains BC and avoids issues where more or less whi= tespace is ignored when, for example, the variable is renamed. * Extending the original proposal, the closing token can be indented withou= t concern. Align it with the starting token, with the assignment line, what= ever. * The closing token could not appear within the text. I=92ve not given this solution deep thought, so I=92m sure there are proble= ms I=92m missing. But if there=92s a good solution to the indentation restr= ictions, I think it would be a huge win. And with the AST-based parser, the= re may be solutions that are possible now that were previously impossible, = which makes this a good time to reconsider the problem. -- Bob Williams SVP, Software Development Newtek Business Services, Inc. =93The Small Business Authority=94 http://www.thesba.com/ Notice: This communication, including attachments, may contain information = that is confidential. It constitutes non-public information intended to be = conveyed only to the designated recipient(s). If the reader or recipient of= this communication is not the intended recipient, an employee or agent of = the intended recipient who is responsible for delivering it to the intended= recipient, or if you believe that you have received this communication in = error, please notify the sender immediately by return e-mail and promptly d= elete this e-mail, including attachments without reading or saving them in = any manner. The unauthorized use, dissemination, distribution, or reproduct= ion of this e-mail, including attachments, is prohibited and may be unlawfu= l. If you have received this email in error, please notify us immediately b= y e-mail or telephone and delete the e-mail and the attachments (if any).