New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trailing space in heredoc delimiter #15427
Comments
From @epaCreated by @epaThe end marker for a here-document must be the exact string, without I appreciate that this is done to be consistent with Unix tradition. Firstly, many commonly used text editors do not show any visual Secondly, we can no longer assume that Perl programmers are familiar Thirdly, Perl has already broken with the behaviour of the shell in In my personal opinion the right fix would be to add a deprecation An alternative would be to simply add a warning when the heredoc Perl Info
|
From @jkeenanOn Wed, 06 Jul 2016 13:50:48 GMT, eda@waniasset.com wrote:
I am unsure as to the specific case you are discussing. In the attachment, the first heredoc is defined with '<<END;'. The second is defined with '<<END ;' In both cases there is no whitespace after the terminator 'END'. Both "work" in the sense that both compile and print -- even though the second definition looks weird. Is that the case you are concerned about? Or something else? Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @AbigailOn Fri, Sep 29, 2017 at 07:27:58PM -0700, James E Keenan via RT wrote:
I think the perceived problem is with a trailing space after the print << END; END END I'm not sure how big a problem this is in practise. In many cases, a Abigail |
From @jkeenanOn Sat, 30 Sep 2017 16:18:58 GMT, abigail@abigail.be wrote:
I agree. I think the feature request should be rejected. Thank you very much. |
From @xsawyerxOn 09/30/2017 07:27 PM, James E Keenan via RT wrote:
Agreed. |
From @epaThanks for your responses. This bug report is based on real-world code; a lot of code (repeated SQL calls, or printing chunks of output) do have repeated heredoc uses, and if those all use the same delimiter (such as END) it is quite easy to silently include a trailing space -- not shown in most editors -- and end up with code that compiles but is wrong. I filed the bug report because it's quite awkward that a space character (moreover, an end-of-line one, which are the most difficult to see) has such a large effect. But forget the suggestion of adding a warning. That gets bogged down in the usual back and forth about perlcritic (which I love, and run over the codebase regularly -- but not in every single edit-test cycle). Could I ask instead whether the whitespace-sensitivity here is really needed? What would happen if heredoc delimiters became like every other language token and weren't affected by space characters after them? They will always be special because they do depend on start of line, but couldn't they be more relaxed about whitespace at the end? Nothing else in the language is as fussy, and we know that with the mixture of different editors in use, trailing spaces tend to creep into code over time. Wouldn't it be a sensible incremental improvement to allow whitespace after these heredoc terminators? Note that the current behaviour is not exactly consistent: if you put the start of the heredoc as '<<END ' with a trailing space, it doesn't get terminated by the 'END ' you specified. The trailing space on the starting heredoc delimiter is silently stripped. Why not strip on the closing delimiter too? |
From @AbigailOn Sun, Oct 01, 2017 at 12:10:57PM -0700, Ed Avis via RT wrote:
This does what you expect it to do: print << "END "; Abigail |
Migrated from rt.perl.org#128557 (status was 'open')
Searchable as RT128557$
The text was updated successfully, but these errors were encountered: