From: Jim Freeze Date: 2011-10-04T15:47:31+09:00 Subject: [ruby-core:39914] Re: Discussion results (here documents with indents) --0016e6d388a5dc067f04ae73769a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm not convinced yet this belongs in Ruby. The only argument I have heard for this is because 'left shifting' a block of text 'looks bad'. However, the solution looks even worse. If a programmer doesn't like the left shift, put the text in a file of it's own or put it in DATA. Does anyone else agree? Does anyone have a better reason to spend time on this? Jim On Tue, Oct 4, 2011 at 1:21 AM, Trans wrote: > On Tue, Oct 4, 2011 at 1:21 AM, "Martin J. D=FCrst" > wrote: > > > > > > On 2011/10/03 22:27, Nikolai Weibull wrote: > >> > >> On Mon, Oct 3, 2011 at 14:16, Yusuke Endoh wrote: > > > >>> How about importing String#margin from Facets? > >>> > >>> my_string =3D<<-END.margin > >>> |doc > >>> |doc > >>> |doc > >>> END > >> > >> Why not implement it by checking the amount of leading whitespace on > >> the first line and strip that amount of whitespace from all subsequent > >> lines? > > > > Yes, something like that seems much more desirable. > > That's essentially what #tabto does. It keeps relative spacing based > on the first line and optionally adds `n` spaces of indention. > > > Examples such as > > > > x =3D %Q{ > > |This > > | is > > | margin controlled! > > }.margin > > > > (from http://trans.github.com/string/ruby/2011/10/02/string-iou.html) > look > > cute, but if the data is actually something like HTML or any other > > kind of structured stuff (or even Ruby, if used for code generation), w= ho > > wants to see all the '|' bars? I'd guess just about nobody. > > The #margin method was written to emulate literal syntax %L. It not > that anyone wants to see the '|' (or whatever character one chooses), > rather it is that it allows for a literal representation of the > multi-line string, whitespace and all. > > --=20 Jim Freeze --0016e6d388a5dc067f04ae73769a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm not convinced yet this belongs in Ruby.
The only argument I hav= e heard for this is because 'left shifting' a block of text 'lo= oks bad'.
However, the solution looks even worse.

If a programmer doesn't like the left shift, put the tex= t in a file of it's own or put it in DATA.

Doe= s anyone else agree? Does anyone have a better reason to spend time on this= ?

Jim


On Tue, Oct 4, 2011 at 1:21 AM, Trans <transfire@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex;">
On Tue, Oct 4, 2011 at 1:21 AM, "Martin J. D=FCrst&q= uot;
<duerst@it.aoyama.ac.jp>= ; wrote:
>
>
> On 2011/10/03 22:27, Nikolai Weibull wrote:
>>
>> On Mon, Oct 3, 2011 at 14:16, Yusuke Endoh<mame@tsg.ne.jp> =A0wrote:
>
>>> How about importing String#margin from Facets?
>>>
>>> =A0my_string =3D<<-END.margin
>>> =A0 =A0|doc
>>> =A0 =A0|doc
>>> =A0 =A0|doc
>>> =A0END
>>
>> Why not implement it by checking the amount of leading whitespace = on
>> the first line and strip that amount of whitespace from all subseq= uent
>> lines?
>
> Yes, something like that seems much more desirable.

That's essentially what #tabto does. It keeps relative spacing ba= sed
on the first line and optionally adds `n` spaces of indention.

> Examples such as
>
> =A0x =3D %Q{
> =A0 =A0 =A0 =A0|This
> =A0 =A0 =A0 =A0| =A0is
> =A0 =A0 =A0 =A0| =A0 =A0margin controlled!
> =A0 =A0 =A0 =A0}.margin
>
> (from http://trans.github.com/string/ruby/2011/10/02= /string-iou.html) look
> cute, but if the data is actually something like HTML or any other
> kind of structured stuff (or even Ruby, if used for code generation), = who
> wants to see all the '|' bars? I'd guess just about nobody= .

The #margin method was written to emulate literal syntax %L. It not that anyone wants to see the '|' (or whatever character one chooses= ),
rather it is that it allows for a literal representation of the
multi-line string, whitespace and all.




--
Jim Freeze
--0016e6d388a5dc067f04ae73769a--