Hello Matz,

On 2011/10/03 6:38, Yukihiro Matsumoto wrote:

> In message "Re: [ruby-core:39840] Re: Discussion results"
>      on Mon, 3 Oct 2011 03:36:02 +0900, Intransition<transfire / gmail.com>  writes:

> |3)  Add margin literal, e.g.
> |
> |>  %L|This is
> |        |  margin
> |        |    controlled.
> |    =>  "This is\n  margin\n    controlled."
> |
> |Nothing sucks more for readability than having to flush a literal
> |string to the left margin in the middle of indented code.
>
> Use here documents.  At least above syntax requires huge overhaul of
> the lexer/parser, that I don't think worth it.

I agree that this should use here document syntax. But that means we 
have to improve here document syntax. I have been annoyed by here 
documents annoyingly and confusingly sticking out of the indenting for 
quite some time, so I came up with the following idea:

We currently have:

my_string = <<HERE
    doc
    doc
    doc
HERE
-> "   doc\n   doc\n   doc\n"

and:

my_string = <<-HERE
    doc
    doc
    doc
          HERE
-> "   doc\n   doc\n   doc\n"

What we'd like to have is something like

my_string = <<+HERE
    doc
    doc
    doc
    HERE
-> "doc\ndoc\ndoc\n"

I have just used '+' as a special character instead of '-', and have 
taken the indent of the ending string as the indent of the whole block 
of text, but that may be too difficult to implement.

Another idea is to require the size of the indent explicitly, e.g. like 
this:

my_string = <<+3HERE
    doc
    doc
    doc
    HERE
-> "doc\ndoc\ndoc\n"

But that may be too brittle (if I change the indenting, I have to change 
the number, too).

The main point is that the source is indented (so it doesn't obstruct 
the overall visual flow of the document, where this here doc is maybe 
inside a module or two and inside a class and a method and maybe inside 
a block and an if and so), but the resulting string doesn't contain 
these indents.

Regards,    Martin.