> On 24 Oct 2017, at 4:58 pm, Nikita Popov <nikita....@gmail.com> wrote: > > On Tue, Oct 24, 2017 at 11:27 AM, Thomas Punt <tp...@hotmail.co.uk> wrote: > >> Hi Christopher, >> >> >>> 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. >> >> 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). > > > 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=8)? Only 8 (ts=4)? Only 4 (ts=2)? 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. > > 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. >> >> >> Other languages follow these semantics of stripping whitespace from new >> lines >> >> according to the indentation of the closing marker, such as Elixir (normal >> """ syntax) >> >> and Ruby (special <<~ syntax). >> >> >> Thanks, >> >> Tom >>
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 ‘content’ lines of the heredoc are indented by 8 spaces, nothing is removed. While I agree that features shouldn’t be surprising, I think converting tabs to spaces or vice-versa *would* be surprising. Also, sidenote: ‘heredoc’ is listed as a spelling mistake with a suggestion of ‘heretic’. Maybe the computers know more than we do. Cheers Stephen -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php