Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100442 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48874 invoked from network); 7 Sep 2017 13:43:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2017 13:43:14 -0000 X-Host-Fingerprint: 95.148.70.109 unknown Received: from [95.148.70.109] ([95.148.70.109:28339] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/71-10715-1FC41B95 for ; Thu, 07 Sep 2017 09:43:13 -0400 Message-ID: To: internals@lists.php.net References: <8C.6B.10715.4A4A0B95@pb1.pair.com> <1E.30.10715.1EE31B95@pb1.pair.com> Date: Thu, 7 Sep 2017 14:43:09 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 95.148.70.109 Subject: Re: [PHP-DEV] Consider only ignoring newlines for final ?> in a file From: ajf@ajf.me (Andrea Faulds) Hi, Nikita Popov wrote: > On Thu, Sep 7, 2017 at 2:43 PM, Andrea Faulds wrote: > >> Hi Nikita, >> >> Nikita Popov wrote: >> >>> >>> It also goes the other way. Whether you want to drop the newline after ?> >>> depends (roughly) on whether the code is control flow (drop) or trailing >>> output (don't drop). If the newline is not dropped anymore it doesn't mean >>> that the output will look nice, it's just going to be broken in a >>> different >>> way. >>> >>> >> I understand that it should be dropped for “control flow” code (maybe not >> the best term, I misunderstood what you meant at first). That's why I >> suggest ignoring the following newline only for the ?> at the end of the >> file, because I can't think of another place where you would have a ?> and >> *not* intend output immediately after it. >> >> So I'm not sure I understand your objection, from that standpoint. Did I >> miss something? >> >> Regards. >> > > I'm referring to code like > >
    > >
  • > >
> > Currently this would produce the output > >
    >
  • Foo
  • >
  • Bar
  • >
> > Without the trailing newline elision it would produce > >
    > >
  • Foo
  • >
  • Bar
  • > >
> > I always assumed that this is the reason why we do this in the first place. Ah. See, it's actually that kind of code that is my problem. A practical example would be:
which currently produces:
foo bar
baz qux
The doubled-up indentation from missing newlines makes it into a mess. And this is even worse in practice when you have more nested control flow. Extra newlines would be fine here, but missing newlines aren't. Thanks. -- Andrea Faulds https://ajf.me/