# Ruby-dev summary 19198-19345

**URL:** <https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126>\
**Category:** ruby-talk\
**Created:** [14 January 2003 17:31 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126 "2003-01-14T17:31:22Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Tom\_Sawyer](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tom\_Sawyer](https://rubytalk.org/u/Tom_Sawyer)\
**Post date:** [15 January 2003 07:04 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/21 "2003-01-15T07:04:21Z")

</div>

it has one simple good reason for use: it allows good form indentation of code  
while conserving storage. all those extra spaces add up. (for example say, in  
HTML gerneration).

> **···**
>
> On Tuesday 14 January 2003 09:08 pm, Yukihiro Matsumoto wrote:
> 
> > Hi,
> > 
> > In message “Re: ruby-dev summary 19198-19345” \> \> on 03/01/15, Paul Brannan [pbrannan@atdesk.com](mailto:pbrannan@atdesk.com) writes:
> > 
> > > Note that the perl community has already given this problem much  
> > > thought:  
> > > [http://dev.perl.org/rfc/162.html](http://dev.perl.org/rfc/162.html)
> > 
> > In message “Re: ruby-dev summary 19198-19345” \> \> on 03/01/15, Matt Armstrong [matt@lickey.com](mailto:matt@lickey.com) writes:
> > 
> > > I do not like this simply because it introduces a problem of tabs -vs-  
> > > spaces.
> > 
> > I’m not sure Perl5 RFC162 is well though or not. But Matt’s comment  
> > is exactly what I thought when I read that. Nobu’s idea is much  
> > better, although I’m not convinced yet.
> > 
> > ```
> > matz.
> > 
> > ```
> 
> –  
> tom sawyer, aka transami  
> [transami@transami.net](mailto:transami@transami.net)
> 
> ```
> .''.
> .''. . *''* :_\/_: .
> :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
> 
> ```
> 
> ## .‘’.: /\ : ./)\ ‘:’\* /\ \* : ‘..’. -=:o:=- :_/_:‘.:::. | ’ _‘’_ \* ‘.'/.’ _(/_’.‘:’.’ : /\ : ::::: = _/_ -= o =- /)\ ’ \* ‘..’ ‘:::’ === \* /\ \* .‘/.'. ‘.\_\_\_\_\_ \* | _.._ : |. |’ .—"| \* | \_ .–’| || | \_| | \* | .-‘| \_\_ | | | || | .-----. | |’ | || | | | | | || | \_\__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |_.

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [16 January 2003 06:10 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/22 "2003-01-16T06:10:54Z")

</div>

Gavin Sinclair wrote:

> One difference between this and a here-doc is the initial newline,  
> which is a shame.

Yes, but the following gets to be idiomatic after a while:

str = %{  
first line  
second line  
}

---

<div class="post-metadata">

**Author:** ![Tom\_Sawyer](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tom\_Sawyer](https://rubytalk.org/u/Tom_Sawyer)\
**Post date:** [16 January 2003 06:20 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/23 "2003-01-16T06:20:22Z")

</div>

sorry, it was Gavin. Gavin done did it! now i’m really creeped-out by those  
here documents. 🙂

> **···**
>
> On Wednesday 15 January 2003 10:59 pm, Hal E. Fulton wrote:
> 
> > Hmm, I think that was someone else.
> > 
> > Hal
> 
> –  
> tom sawyer, aka transami  
> [transami@transami.net](mailto:transami@transami.net)
> 
> ```
> .''.
> .''. . *''* :_\/_: .
> :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
> 
> ```
> 
> ## .‘’.: /\ : ./)\ ‘:’\* /\ \* : ‘..’. -=:o:=- :_/_:‘.:::. | ’ _‘’_ \* ‘.'/.’ _(/_’.‘:’.’ : /\ : ::::: = _/_ -= o =- /)\ ’ \* ‘..’ ‘:::’ === \* /\ \* .‘/.'. ‘.\_\_\_\_\_ \* | _.._ : |. |’ .—"| \* | \_ .–’| || | \_| | \* | .-‘| \_\_ | | | || | .-----. | |’ | || | | | | | || | \_\__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |_.

---

<div class="post-metadata">

**Author:** ![Tom\_Sawyer](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tom\_Sawyer](https://rubytalk.org/u/Tom_Sawyer)\
**Post date:** [16 January 2003 06:49 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/24 "2003-01-16T06:49:03Z")

</div>

very cool Gavin, unfortunately i can’t use that since i have all my tabs  
converted to spaces by my editor. is there a spaces version perhaps?

> **···**
>
> On Wednesday 15 January 2003 10:08 pm, Gavin Sinclair wrote:
> 
> > s = %Q{  
> > hi  
> > how are you?  
> > }.tabto(0)
> 
> –  
> tom sawyer, aka transami  
> [transami@transami.net](mailto:transami@transami.net)
> 
> ```
> .''.
> .''. . *''* :_\/_: .
> :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
> 
> ```
> 
> ## .‘’.: /\ : ./)\ ‘:’\* /\ \* : ‘..’. -=:o:=- :_/_:‘.:::. | ’ _‘’_ \* ‘.'/.’ _(/_’.‘:’.’ : /\ : ::::: = _/_ -= o =- /)\ ’ \* ‘..’ ‘:::’ === \* /\ \* .‘/.'. ‘.\_\_\_\_\_ \* | _.._ : |. |’ .—"| \* | \_ .–’| || | \_| | \* | .-‘| \_\_ | | | || | .-----. | |’ | || | | | | | || | \_\__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |_.

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [16 January 2003 08:33 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/25 "2003-01-16T08:33:18Z")

</div>

Hi,

> I think I might start using that more often. It’s nice, and it’s  
> easier to chain. e.g. with an appropriate String#tabto(n) method (a  
> la StringFormattingFunctions on the Wiki), you can resolve the  
> indentation like so:
> 
> s = %Q{  
> hi  
> how are you?  
> }.tabto(0)
> 
> Which gives “\nhi\n how are you?\n”. That code would highlight fine,  
> whereas using here-docs can sometimes be troublesome.
> 
> One difference between this and a here-doc is the initial newline,  
> which is a shame.

One more difference. tabto strips after string interpolcation,  
whereas here-doc does before it.

hi = " hi"  
s0 = %q{  
#{hi}  
how are you?  
}.tabto(0)

# =\> “\nhi\nhow are you?\n”

s1 = \<\<|EOS  
\>#{hi}  
\> how are you?  
EOS

# =\> “\n hi\n how are you?\n”

> **···**
>
> At Thu, 16 Jan 2003 14:08:58 +0900, Gavin Sinclair wrote:
> 
> –  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![Jim\_Weirich2](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@Jim\_Weirich2](https://rubytalk.org/u/Jim_Weirich2)\
**Post date:** [17 January 2003 01:44 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/26 "2003-01-17T01:44:15Z")

</div>

> Note also that if the text you are printing includes a } character, this  
> won’t work. You’ll have to use %Q instead or %Q%some string% (or some  
> variant) instead,

Well, only of the {}'s are unbalanced. For Example …

$ irb --simple-prompt

> > s = %Q{ this is { just a } test }  
> > =\> " this is { just a } test "

> **···**
>
> On Thu, 2003-01-16 at 09:58, Paul Brannan wrote:
> 
> ## – – Jim Weirich [jweirich@one.net](mailto:jweirich@one.net)[http://w3.one.net/~jweirich](http://w3.one.net/~jweirich)
> 
> “Beware of bugs in the above code; I have only proved it correct,  
> not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

---

<div class="post-metadata">

**Author:** ![Chris18](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@Chris18](https://rubytalk.org/u/Chris18)\
**Post date:** [15 January 2003 03:49 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/27 "2003-01-15T03:49:12Z")

</div>

I like it, too.

I think I like the Perl way better, but either way is nicer than none at  
all.

🙂

Chris

> **···**
>
> ----- Original Message -----  
> From: “Daniel Carrera” [dcarrera@math.umd.edu](mailto:dcarrera@math.umd.edu)  
> Newsgroups: comp.lang.ruby  
> Sent: Tuesday, January 14, 2003 6:56 PM  
> Subject: Re: ruby-dev summary 19198-19345
> 
> Come to think of it, this feature _is_ really useful. I’d like to see it  
> implemented.
> 
> Cheers,  
> Daniel Carrera  
> Graduate Teaching Assistant. Math Dept.  
> University of Maryland. (301) 405-5137
> 
> On Wed, 15 Jan 2003, Gavin Sinclair wrote:
> 
> > On Wednesday, January 15, 2003, 12:36:43 PM, Daniel wrote:
> > 
> > > On Wed, 15 Jan 2003, Gavin Sinclair wrote:
> > 
> > > > > ```
> > > > > p <<-|EOS
> > > > > > foo
> > > > > > bar
> > > > > EOS
> > > > > # => " foo\n bar\n".
> > > > > 
> > > > > ```
> > > 
> > > [snip]
> > > 
> > > > Anyway. I want this functionality so bad I can taste it.
> > 
> > > Gavin, maybe I’m missing something but I’m not sure I understand the  
> > > usefulness of this. The only example I can think of where I might like  
> > > this is when I have lots of indentation:
> > 
> > > def function  
> > > if (condition)  
> > > p \<\<-|EOH  
> > > \>Blah blah blah  
> > > \>Blah blah blah  
> > > EOH  
> > > end  
> > > end
> > 
> > Well, that’s a good example! Here-documents can come up anywhere.
> > 
> > > Is this the purpose of this feature? Or am I missing something?
> > 
> > Even with little/no indentation, the proposed feature would be useful  
> > to me. I usually indent code in posts, but here will put is as if it  
> > were in a Ruby program.
> > 
> > USAGE =\<\<-|EOU
> > 
> > > Usage: froboz [-q] [-o DIR] files…  
> > > -q: quiet operation  
> > > -o: output to DIR
> > > 
> > > (c) 2003 Widgets Co  
> > > EOU
> > 
> > --------- vs ---------
> > 
> > USAGE =\<\<-EOU  
> > Usage: froboz [-q] [-o DIR] files…  
> > -q: quiet operation  
> > -o: output to DIR
> > 
> > (c) 2003 Widgets Co  
> > EOU
> > 
> > Being able to indent you text gives the same benefit as all  
> > indentation: highlights code structure.
> > 
> > Gavin

---

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [15 January 2003 04:38 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/28 "2003-01-15T04:38:06Z")

</div>

> [matz@ruby-lang.org](mailto:matz@ruby-lang.org) (Yukihiro Matsumoto) writes:

> > > I do not like this simply because it introduces a problem of tabs -vs-  
> > > spaces.
> > 
> > I’m not sure Perl5 RFC162 is well though or not. But Matt’s comment  
> > is exactly what I thought when I read that. Nobu’s idea is much  
> > better, although I’m not convinced yet.

Why are you not convinced, Matz? YAGNI? Or implementation difficulty?  
I think it’s a very good solution to a very real problem. The problem  
is only aesthetic, but no less real for that.

If I were implementing it, I’d limit the “special character” to ‘|’,  
unless someone demonstrated a reason why this shouldn’t be the case.

> What I do not like about Nobu’s idea is that the here document may be  
> harder to edit, since every line must have the leading | character.  
> The extra editing pain may outweigh any benefit.

Editing this in Vim would be easier than slipping on a banana peel.  
Surely this must also be the case with Emacs?

And the worst that can be said about the feature is this: if the  
drawback (editing) outweighs the advantage (which is subjective, but  
to some people, great), then you don’t have to use it.

Gavin

> **···**
>
> On Wednesday, January 15, 2003, 3:17:11 PM, Matt wrote:
> 
> > > In message “Re: ruby-dev summary 19198-19345” \>\> on 03/01/15, Matt Armstrong [matt@lickey.com](mailto:matt@lickey.com) writes:

---

<div class="post-metadata">

**Author:** ![Tom\_Sawyer](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tom\_Sawyer](https://rubytalk.org/u/Tom_Sawyer)\
**Post date:** [16 January 2003 06:16 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/29 "2003-01-16T06:16:38Z")

</div>

nice, never thought of that. then again you can also use the first line too:

str = %Q{first line  
second line}

> **···**
>
> On Wednesday 15 January 2003 11:10 pm, Joel VanderWerf wrote:
> 
> > Gavin Sinclair wrote:
> > 
> > > One difference between this and a here-doc is the initial newline,  
> > > which is a shame.
> > 
> > Yes, but the following gets to be idiomatic after a while:
> > 
> > str = %{  
> > first line  
> > second line  
> > }
> 
> –  
> tom sawyer, aka transami  
> [transami@transami.net](mailto:transami@transami.net)
> 
> ```
> .''.
> .''. . *''* :_\/_: .
> :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
> 
> ```
> 
> ## .‘’.: /\ : ./)\ ‘:’\* /\ \* : ‘..’. -=:o:=- :_/_:‘.:::. | ’ _‘’_ \* ‘.'/.’ _(/_’.‘:’.’ : /\ : ::::: = _/_ -= o =- /)\ ’ \* ‘..’ ‘:::’ === \* /\ \* .‘/.'. ‘.\_\_\_\_\_ \* | _.._ : |. |’ .—"| \* | \_ .–’| || | \_| | \* | .-‘| \_\_ | | | || | .-----. | |’ | || | | | | | || | \_\__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |_.

---

<div class="post-metadata">

**Author:** ![Dmitri\_Colebatch](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@Dmitri\_Colebatch](https://rubytalk.org/u/Dmitri_Colebatch)\
**Post date:** [16 January 2003 06:53 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/30 "2003-01-16T06:53:25Z")

</div>

Tom Sawyer wrote:

> **···**
>
> > On Wednesday 15 January 2003 10:08 pm, Gavin Sinclair wrote:
> > 
> > > s = %Q{  
> > > hi  
> > > how are you?  
> > > }.tabto(0)
> > 
> > very cool Gavin, unfortunately i can’t use that since i have all my tabs  
> > converted to spaces by my editor. is there a spaces version perhaps?
> 
> (untested)
> 
> ```
> .sub!(/^ *//)
> 
> ```
> 
> would do the trick yes?
> 
> cheers  
> dim

---

<div class="post-metadata">

**Author:** ![Yukihiro\_Matsumoto2](https://avatars.discourse-cdn.com/v4/letter/y/b9e5f3/32.png) [@Yukihiro\_Matsumoto2](https://rubytalk.org/u/Yukihiro_Matsumoto2)\
**Post date:** [15 January 2003 05:39 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/31 "2003-01-15T05:39:36Z")

</div>

Hi,

> **···**
>
> In message “Re: ruby-dev summary 19198-19345” on 03/01/15, Gavin Sinclair [gsinclair@soyabean.com.au](mailto:gsinclair@soyabean.com.au) writes:
> 
> > Why are you not convinced, Matz? YAGNI? Or implementation difficulty?  
> > I think it’s a very good solution to a very real problem. The problem  
> > is only aesthetic, but no less real for that.
> 
> Nobu already made a patch to implement it. I feel like it can make  
> programs more cryptic. “\<\<-|FOO”?? WHAT DOES IT MEAN?
> 
> Other heredoc notations follow shell convention, so that there’s  
> nothing new in syntax. One of Ruby’s secret is to be slow to merge  
> new syntax.
> 
> ```
> matz.
> 
> ```

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [16 January 2003 08:08 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/32 "2003-01-16T08:08:38Z")

</div>

Dmitri Colebatch wrote:

> Tom Sawyer wrote:
> 
> > > s = %Q{  
> > > hi  
> > > how are you?  
> > > }.tabto(0)
> > 
> > very cool Gavin, unfortunately i can’t use that since i have all my  
> > tabs converted to spaces by my editor. is there a spaces version perhaps?

It is the spaces version, just with a bad name. I use spaces to emulate  
hard tabs, too.

> (untested)
> 
> ```
> .sub!(/^ *//)
> 
> ```
> 
> would do the trick yes?

Nope, #tabto preserves relative indentation of lines. I probably should  
have called it something else, like “indent\_to” or “indent\_block”.

If anyone has a better name, please put add it to:

> **[WebMD - Better information. Better health.](https://www.webmd.com/?StringFormattingFunctions)**
>
> The leading source for trustworthy and timely health and medical news and information. Providing credible health information, supportive community, and educational services by blending award-winning expertise in content, community services, expert...

> **···**
>
> > > On Wednesday 15 January 2003 10:08 pm, Gavin Sinclair wrote:

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [15 January 2003 05:55 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/33 "2003-01-15T05:55:09Z")

</div>

Yukihiro Matsumoto wrote:

> Hi,
> 
> > Why are you not convinced, Matz? YAGNI? Or implementation difficulty?  
> > I think it’s a very good solution to a very real problem. The problem  
> > is only aesthetic, but no less real for that.
> 
> Nobu already made a patch to implement it. I feel like it can make  
> programs more cryptic. “\<\<-|FOO”?? WHAT DOES IT MEAN?
> 
> Other heredoc notations follow shell convention, so that there’s  
> nothing new in syntax. One of Ruby’s secret is to be slow to merge  
> new syntax.
> 
> ```
> matz.
> 
> ```

It’s a great secret. Keep the syntax simple, the core classes clean, and  
let library developers fill in minor details like this.

This works well enough for me, and I don’t have to type | characters.  
(But it doesn’t solve the hard-tabs-versus-spaces problem; I just don’t  
use hard tabs.)

class String

```
# Tabs left or right by n chars, using spaces
def tab(n)
  if n >= 0
    gsub(/^/, ' ' * n)
  else
    gsub(/^ {0,#{-n}}/, "")
  end
end

# Preserves relative tabbing.
# The first non-empty line ends up with n spaces before nonspace.
def tabto(n)
  if self =~ /^( *)\S/
    tab(n - $1.length)
  else
    self
  end
end

```

end

```
   str = %{\
     header
       subhead
         text
   }.tabto(2)

```

puts str

===output===  
header  
subhead  
text

> **···**
>
> > In message “Re: ruby-dev summary 19198-19345” \> on 03/01/15, Gavin Sinclair [gsinclair@soyabean.com.au](mailto:gsinclair@soyabean.com.au) writes:

---

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [15 January 2003 06:21 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/34 "2003-01-15T06:21:10Z")

</div>

When I first saw it mentioned in a ruby-dev summary several weeks ago,  
I knew instantly what it meant. You see the | representing a left  
margin, and it’s obvious.

The secret is already violated with regard to \<\<-EOF (i.e. allowing an  
indented end marker). Well, I just tried it in bash, and it didn’t  
allow an indented EOF. Maybe other sheels do.

Gavin

> **···**
>
> On Wednesday, January 15, 2003, 4:39:36 PM, Yukihiro wrote:
> 
> > Hi,
> 
> > In message “Re: ruby-dev summary 19198-19345” \> on 03/01/15, Gavin Sinclair [gsinclair@soyabean.com.au](mailto:gsinclair@soyabean.com.au) writes:
> 
> > > Why are you not convinced, Matz? YAGNI? Or implementation difficulty?  
> > > I think it’s a very good solution to a very real problem. The problem  
> > > is only aesthetic, but no less real for that.
> 
> > Nobu already made a patch to implement it. I feel like it can make  
> > programs more cryptic. “\<\<-|FOO”?? WHAT DOES IT MEAN?
> 
> > Other heredoc notations follow shell convention, so that there’s  
> > nothing new in syntax. One of Ruby’s secret is to be slow to merge  
> > new syntax.

---

<div class="post-metadata">

**Author:** ![HAL\_9000](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@HAL\_9000](https://rubytalk.org/u/HAL_9000)\
**Post date:** [15 January 2003 06:54 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/35 "2003-01-15T06:54:50Z")

</div>

> Hi,
> 
> > Why are you not convinced, Matz? YAGNI? Or implementation difficulty?  
> > I think it’s a very good solution to a very real problem. The problem  
> > is only aesthetic, but no less real for that.
> 
> Nobu already made a patch to implement it. I feel like it can make  
> programs more cryptic. “\<\<-|FOO”?? WHAT DOES IT MEAN?

If you’re not used to it, even \<\<-FOO is cryptic.

Personally, I’d dispense with the hyphen in this  
case… only one punctuation mark is needed  
in order to remove ambiguity: \<\<|FOO

> Other heredoc notations follow shell convention, so that there’s  
> nothing new in syntax. One of Ruby’s secret is to be slow to merge  
> new syntax.

We all trust your judgment, as you have treated us  
very well in the past. 🙂 A (mineral) ruby is not  
produced quickly, nor is a (software) Ruby.

Hal

> **···**
>
> ----- Original Message -----  
> From: “Yukihiro Matsumoto” [matz@ruby-lang.org](mailto:matz@ruby-lang.org)  
> To: “ruby-talk ML” [ruby-talk@ruby-lang.org](mailto:ruby-talk@ruby-lang.org)  
> Sent: Tuesday, January 14, 2003 11:39 PM  
> Subject: Re: ruby-dev summary 19198-19345
> 
> > In message “Re: ruby-dev summary 19198-19345” \> on 03/01/15, Gavin Sinclair [gsinclair@soyabean.com.au](mailto:gsinclair@soyabean.com.au) writes:

---

<div class="post-metadata">

**Author:** ![Matt\_Armstrong](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Matt\_Armstrong](https://rubytalk.org/u/Matt_Armstrong)\
**Post date:** [15 January 2003 15:39 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/36 "2003-01-15T15:39:54Z")

</div>

[matz@ruby-lang.org](mailto:matz@ruby-lang.org) (Yukihiro Matsumoto) writes:

> Nobu already made a patch to implement it. I feel like it can make  
> programs more cryptic. “\<\<-|FOO”?? WHAT DOES IT MEAN?

I just though, why not “\<\<|FOO”. In other words, the ‘-’ in there  
doesn’t serve much purpose.

s = \<\<|FOO  
\>this  
\> is  
\> my  
\> text  
FOO

---

<div class="post-metadata">

**Author:** ![Tom\_Sawyer](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tom\_Sawyer](https://rubytalk.org/u/Tom_Sawyer)\
**Post date:** [16 January 2003 14:16 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/37 "2003-01-16T14:16:42Z")

</div>

> It is the spaces version, just with a bad name. I use spaces to emulate  
> hard tabs, too.

great! i love it!

> [http://www.rubygarden.org/ruby?StringFormattingFunctions](http://www.rubygarden.org/ruby?StringFormattingFunctions)

i lloked these over. mind if i add them to my general purpose library  
(tomslib/rubylib?)

i thought a tad on the names to, i think they’re mostly fine, but seems to me  
it might be a touch better if they were:

indent(n)  
indent\_to(n)  
indent\_all(n)

and then with aliases of:

tab(n)  
tab\_to(n)  
tab\_all(n)

> **···**
>
> On Thursday 16 January 2003 01:08 am, Joel VanderWerf wrote:
> 
> –  
> tom sawyer, aka transami  
> [transami@transami.net](mailto:transami@transami.net)
> 
> ```
> .''.
> .''. . *''* :_\/_: .
> :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
> 
> ```
> 
> ## .‘’.: /\ : ./)\ ‘:’\* /\ \* : ‘..’. -=:o:=- :_/_:‘.:::. | ’ _‘’_ \* ‘.'/.’ _(/_’.‘:’.’ : /\ : ::::: = _/_ -= o =- /)\ ’ \* ‘..’ ‘:::’ === \* /\ \* .‘/.'. ‘.\_\_\_\_\_ \* | _.._ : |. |’ .—"| \* | \_ .–’| || | \_| | \* | .-‘| \_\_ | | | || | .-----. | |’ | || | | | | | || | \_\__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |_.

---

<div class="post-metadata">

**Author:** ![Yukihiro\_Matsumoto2](https://avatars.discourse-cdn.com/v4/letter/y/b9e5f3/32.png) [@Yukihiro\_Matsumoto2](https://rubytalk.org/u/Yukihiro_Matsumoto2)\
**Post date:** [15 January 2003 07:16 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/38 "2003-01-15T07:16:32Z")

</div>

Hi,

> When I first saw it mentioned in a ruby-dev summary several weeks ago,  
> I knew instantly what it meant. You see the | representing a left  
> margin, and it’s obvious.

I don’t forget there’s one feel like that. Thank you.

> The secret is already violated with regard to \<\<-EOF (i.e. allowing an  
> indented end marker). Well, I just tried it in bash, and it didn’t  
> allow an indented EOF. Maybe other sheels do.

sh has “\<\<-EOF”.

```
						matz.

```

> **···**
>
> In message “Re: ruby-dev summary 19198-19345” on 03/01/15, Gavin Sinclair [gsinclair@soyabean.com.au](mailto:gsinclair@soyabean.com.au) writes:

---

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [15 January 2003 15:53 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/39 "2003-01-15T15:53:08Z")

</div>

> [matz@ruby-lang.org](mailto:matz@ruby-lang.org) (Yukihiro Matsumoto) writes:

> > Nobu already made a patch to implement it. I feel like it can make  
> > programs more cryptic. “\<\<-|FOO”?? WHAT DOES IT MEAN?

> I just though, why not “\<\<|FOO”. In other words, the ‘-’ in there  
> doesn’t serve much purpose.

> s = \<\<|FOO  
> \>this  
> \> is  
> \> my  
> \> text  
> FOO

To me, the ‘-’ means the same that it always does: it allows the  
end-of-document marker to be indented. I don’t see why that should  
change. In other words, the example given above is an incomplete  
here-document, based on the assumption in the following section.

What happens if a here-doc is specified to have the left margin (‘|’)  
but for one or more lines it is not used, as in:

s = \<\<-|EOS  
\> One  
\> Two  
Three  
\> Four  
EOS

puts s

I think the correct output is:  
One  
Two  
Three  
Four  
(end of output)

In that case, it’s pretty easy to see what becomes of the quoted  
example at the top. The fifth line is " FOO".

At the end of the day, the “-” and (proposed) “|” features of Ruby  
here-documents are independent of each other.

Gavin

> **···**
>
> On Thursday, January 16, 2003, 2:39:54 AM, Matt wrote:

---

<div class="post-metadata">

**Author:** ![Dave\_Mail\_Archive](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@Dave\_Mail\_Archive](https://rubytalk.org/u/Dave_Mail_Archive)\
**Post date:** [15 January 2003 16:00 UTC](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126/40 "2003-01-15T16:00:54Z")

</div>

Matt Armstrong wrote:

> I just though, why not “\<\<|FOO”. In other words, the ‘-’ in there  
> doesn’t serve much purpose.
> 
> s = \<\<|FOO  
> \>this  
> \> is  
> \> my  
> \> text  
> FOO

In fact, neither does the ‘FOO’

```
s = <<|Now is the time
       > For all good men
       > to code Ruby
p s.length

```

So any line that _doesn’t_ start with the given delimiter (ignoring  
leading whitespace) ends the string.

Cheers

Dave

[Previous page](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126.md?page=1)

[Next page](https://rubytalk.org/t/ruby-dev-summary-19198-19345/4126.md?page=3)
