Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100976 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16501 invoked from network); 28 Oct 2017 08:05:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Oct 2017 08:05:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=php-lists@koalephant.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php-lists@koalephant.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain koalephant.com designates 206.123.115.54 as permitted sender) X-PHP-List-Original-Sender: php-lists@koalephant.com X-Host-Fingerprint: 206.123.115.54 mail1.25mail.st Received: from [206.123.115.54] ([206.123.115.54:47438] helo=mail1.25mail.st) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/23-28573-56A34F95 for ; Sat, 28 Oct 2017 04:05:59 -0400 Received: from [10.0.1.29] (unknown [49.48.245.138]) by mail1.25mail.st (Postfix) with ESMTPSA id C6BFD60425; Sat, 28 Oct 2017 08:05:43 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.0 \(3445.1.7\)) In-Reply-To: Date: Sat, 28 Oct 2017 15:05:39 +0700 Cc: Thomas Punt , Christopher Jones , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <4BD31E87-540B-42A3-9823-9FAFD21EEF0A@koalephant.com> References: <0ac37ce7-62f4-7b1c-5b3d-2d2f45190f07@oracle.com> To: Nikita Popov X-Mailer: Apple Mail (2.3445.1.7) Subject: Re: [PHP-DEV] [RFC] Flexible Heredoc and Nowdoc Syntaxes From: php-lists@koalephant.com (Stephen Reay) > On 24 Oct 2017, at 4:58 pm, Nikita Popov wrote: >=20 > On Tue, Oct 24, 2017 at 11:27 AM, Thomas Punt = wrote: >=20 >> Hi Christopher, >>=20 >>=20 >>> I like the added flexibility in placement of the end token, but I = think >> requiring only tabs or spaces, and stripping whitespace from all >> {here|now}doc >>> lines is error prone and adds unnecessary complexity. >>=20 >> I agree that the requirement for using either tabs or spaces is not >> necessary, but >> I included it because it does help with readability when looking at = the >> indentation >> level of the heredoc and nowdoc (and subsequently how much whitespace = will >> be stripped from each line). >=20 >=20 > It's not just a question of readability. You just can't strip a mixed > space/tab indentation unless you specify a tab width. If one line is > indented with two tabs and the other with 16 spaces, what do you = strip? All > 16 spaces (ts=3D8)? Only 8 (ts=3D4)? Only 4 (ts=3D2)? Unless we want = to specify > the One True Tab Width or introduce an ini setting for this, it's not > really possible to handle this in a reasonable way. >=20 > With respect to the stripping of whitespace, however, >> I feel that this is definitely necessary. If it was not stripped, = then >> indenting the >> closing token and body will cause a lot of whitespace to prepend = every >> line in >> the body of text. This is definitely not desirable, and may cause >> programmers to >> continue to not indent the body of the heredoc/nowdoc, which leads us = back >> to >> where we currently are of having indentation of code ruined with such >> syntaxes. >>=20 >>=20 >> Other languages follow these semantics of stripping whitespace from = new >> lines >>=20 >> according to the indentation of the closing marker, such as Elixir = (normal >> """ syntax) >>=20 >> and Ruby (special <<~ syntax). >>=20 >>=20 >> Thanks, >>=20 >> Tom >>=20 Hi Nikita, I disagree. To me this change would simply mean that the literal exact = white-space string preceding the end marker is removed as a prefix from = all lines. So if you have an end marker intended by two tab characters, but all the = =E2=80=98content=E2=80=99 lines of the heredoc are indented by 8 spaces, = nothing is removed. While I agree that features shouldn=E2=80=99t be surprising, I think = converting tabs to spaces or vice-versa *would* be surprising. Also, sidenote: =E2=80=98heredoc=E2=80=99 is listed as a spelling = mistake with a suggestion of =E2=80=98heretic=E2=80=99. Maybe the = computers know more than we do. Cheers Stephen=