Skip to content
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

Heredocs are de-indented after interpolation, but should be de-indented before, in Rakudo #3103

Closed
p6rt opened this issue Apr 13, 2013 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 13, 2013

Migrated from rt.perl.org#117603 (status was 'resolved')

Searchable as RT117603$

@p6rt
Copy link
Author

p6rt commented Apr 13, 2013

From @masak

<masak> I don't think we ever got an RT ticket for
http://irclog.perlgeek.de/perl6/2012-12-12#i_6236512
<masak> rn​: https://gist.github.com/masak/5379061
<p6eval> niecza v24-37-gf9c8fc2​: OUTPUT«Line 1␤Line 2␤Line 3␤Line 4␤␤»
<p6eval> ..rakudo 070f3a​: OUTPUT«Asked to remove 4 spaces, but the
shortest indent is 0 spaces in block at /tmp/HZMtZbv4Ag​:3␤␤Line
1␤Line 2␤Line 3␤Line 4␤␤»
* masak submits rakudobug

For context, here's the gist​:

say qq​:to/END/;
  Line 1
  {foo}
  Line 4
  END

sub foo { "Line 2\nLine 3" }

And here's the prior conversation in the backlog​:

<masak> at some point I'd like us to have a deep discussion about
heredocs, indentation, and interpolation.
<masak> TimToady​: should the indentation from an interpolated variable
figure in the de-indentation of a heredoc?
<masak> TimToady​: S02 contains *one* example of qq​:to, and that
example doesn't address the subtle question of what happens first​:
.indent(*) or variable interpolation. what's your take on which one
happens first?
<TimToady> masak, jnthn​: the intent is that heredoc indent is a
textual feature, not a shortcut for a run-time feature
<TimToady> yes it's harder, but STD does it that way (and so niecza, I think)
<jnthn> TimToady​: That means...breaking the string up and indenting
each piece of it separately and knowing not to if the piece in
question doesn't contain a new line :/
<jnthn> I guess the AST already has it that way so it's "just" a bit
more post-processing.
<TimToady> jnthn​: only a textual newline
<jnthn> TimToady​: textual as in the source?
<TimToady> yes
<jnthn> TimToady​: It's a pain and I think it's too clever for it's own
good. It's doable I guess.
<TimToady> it's what the user wants, not the implementor
<jnthn> As I user I like semantics I can easily grok
<TimToady> this is easy to grok
<jnthn> As a teacher I like semantics I can easily explain
<jnthn> "It forms the string and does what indent would do" is easy.
<TimToady> there's an artificial left boundary at that point
<TimToady> just move the line over
<TimToady> what you see is what you get, if you just moved the text
over to the left margin
<jnthn> Hm, true
<TimToady> it's visually the right thing to do
<moritz> is that boundary determined by the indention of the heredoc
terminator, or by the left border of the content?
<TimToady> terminator
<TimToady> heredoc indent is only for not forcing the user to outdent
heredocs like you have to do in p5
<TimToady> or however you say that in English
<TimToady> it's an aid to formatting code, is all

@p6rt
Copy link
Author

p6rt commented Jul 12, 2013

From @timo

Fixed in commits 7157e1e and 3f1c71d.

Heredoc trimming now always happens (and warns) at compile-time; the
interpolated contents are thus not touched.

There are also a few more tests in roast, added in commits c02bce1 and
79af625.

@p6rt
Copy link
Author

p6rt commented Jul 12, 2013

@timo - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Jul 12, 2013
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant