Ruby-dev summary 19198-19345

Hello,

Here is a summary of ruby-dev ML from the end of December
to last week.

[ruby-dev:19198, 19277] Ruby 1.8.0 / yield(nil) and yield()

Masatoshi SEKI pointed out that the behavior of yield(nil) has
been changed to the same as yield() in 1.8.0-preview1.

ruby-1.6.8:
def foo(*arg)
yield(*arg)
end
foo() {|*x| p x} # -> []
foo(nil) {|*x| p x} # -> [nil]
foo(1) {|*x| p x} # -> [1]

ruby-1.8.0-preview1:
foo() {|*x| p x} # -> []
foo(nil) {|*x| p x} # -> [], same as foo()
foo(1) {|*x| p x} # -> [1]

Matz changed 1.8.0 sources to work same as 1.6.8. Also he and Tanaka
Akira started discussion for how this behavior should work.

[ruby-dev:19233] [1.8] speed

Forking from [ruby-talk:59980] thread, investigation for memory
allocation and GC performance has been started, based on reports of
[ruby-talk:59662], [ruby-dev:18482] and [ruby-dev:19242]. They found
the problem in details of the current implementation. Some GC
improvement patches were posted.

[ruby-dev:19261] lstripped here-document

Nobu Nakada proposed the idea for a new here-document style inspired by
[ruby-talk:50473]. In his idea, if you assign a character (except
quotes) after the here-document indicator “<<-”, All blanks and
assigned character at the head of each line will be deleted.
Here is a example assigning ‘|’:

p <<-|EOS
  >  foo
  >    bar
EOS
# => "  foo\n    bar\n".

He already posted a patch to add this function. Matz wants any
comments for the idea from all Rubyists.

[ruby-dev:19287] Re: Class.inherited

From [ruby-talk:60377], Matz is considering Class.inherited invocation
timing. He has a plan to change Class.inherited to be invoked after the
class is declared.

[ruby-dev:19331] [Oniguruma] Version 1.5

K.Kosako announced that the new version of Oniguruma, another regexp
engine for ruby has been released. You can get it from:

ftp://ftp.ruby-lang.org/pub/ruby/contrib/onigd20030109.tar.gz

Followings are major changes in the announcement:

  1. reimplimented whole optimization routine
  2. rewrote test cases
  3. implemented POSIX APIs

Kazuo Saito ksaito@uranus.dti.ne.jp

Wow, I’ve been wanting this behavior in one language or another for years
for when you want a multiline string assigned to a variable that’s indented.

I vote yes.

Jim

···

On Wed, 15 Jan 2003 02:31:22 +0900 Kazuo Saito ksaito@uranus.dti.ne.jp wrote:

Nobu Nakada proposed the idea for a new here-document style inspired by
[ruby-talk:50473]. In his idea, if you assign a character (except
quotes) after the here-document indicator “<<-”, All blanks and
assigned character at the head of each line will be deleted.
Here is a example assigning ‘|’:

p <<-|EOS
  >  foo
  >    bar
EOS
# => "  foo\n    bar\n".

He already posted a patch to add this function. Matz wants any
comments for the idea from all Rubyists.

I like the idea of being able to indent my here documents. I’m not
convinced that the proposed solution is the best solution, though.

Note that the perl community has already given this problem much
thought:
http://dev.perl.org/rfc/162.html

.From what I can gather, the proposed perl solution would look like this
in Ruby:

p <<<EOS
foo
bar
EOS
#=> " foo\n bar\n"

(that is, strip any leading whitespace that is indented the same as the
terminator).

There’s something to be said for using the same syntax as perl6, since
it will make translation easier and reduce confusion.

I think a similar argument was made for not including certain books from
the Septuagint in the Christian Bible.

Paul

···

On Wed, Jan 15, 2003 at 02:31:22AM +0900, Kazuo Saito wrote:

[ruby-dev:19261] lstripped here-document

Nobu Nakada proposed the idea for a new here-document style inspired by
[ruby-talk:50473]. In his idea, if you assign a character (except
quotes) after the here-document indicator “<<-”, All blanks and
assigned character at the head of each line will be deleted.
Here is a example assigning ‘|’:

p <<-|EOS
  >  foo
  >    bar
EOS
# => "  foo\n    bar\n".

He already posted a patch to add this function. Matz wants any
comments for the idea from all Rubyists.

Nobu Nakada proposed the idea for a new here-document style inspired by
[ruby-talk:50473]. In his idea, if you assign a character (except
quotes) after the here-document indicator “<<-”, All blanks and
assigned character at the head of each line will be deleted.
Here is a example assigning ‘|’:

p <<-|EOS
  >  foo
  >    bar
EOS
# => "  foo\n    bar\n".

He already posted a patch to add this function. Matz wants any
comments for the idea from all Rubyists.

i have been wanting this myself. GOOD IDEA! i wonder if the - is neccessary?
wouldn’t <<| be enough? personally, i have always felt that << is useless and
always use <<-. is there any good reason to keep << distinct from <<-?
dosen’t <<- serve all purposes? since << has to be flush to the beginning of
the line? <<- can be, but dosen’t have to be. is that correct?

then again wouldn’t something like this be simpler:

p <<| foo
> bar
puts p

and that’s it, such that the string is completed by the fact that there is no
/^\s*|/ match on the 3rd line. just thinking aloud here.

···

On Tuesday 14 January 2003 10:31 am, Kazuo Saito wrote:


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.

Well, if he wants comments from all Rubyists, … that’s a lot of
comments.

Anyway. I want this functionality so bad I can taste it.

The Perl6 idea is interesting, and on the face of simpler. But the
idea above is quite elegant and pretty, and with a good editor, easy
to edit.

Gavin

···

On Wednesday, January 15, 2003, 4:31:22 AM, Kazuo wrote:

[ruby-dev:19261] lstripped here-document

Nobu Nakada proposed the idea for a new here-document style inspired by
[ruby-talk:50473]. In his idea, if you assign a character (except
quotes) after the here-document indicator “<<-”, All blanks and
assigned character at the head of each line will be deleted.
Here is a example assigning ‘|’:

p <<-|EOS
  >  foo
  >    bar
EOS
# => "  foo\n    bar\n".

He already posted a patch to add this function. Matz wants any
comments for the idea from all Rubyists.

Paul Brannan wrote:

There’s something to be said for using the same syntax as perl6, since
it will make translation easier and reduce confusion.

I think a similar argument was made for not including certain books from
the Septuagint in the Christian Bible.

The books were not included because they didn’t use perl6 syntax? :wink:

hey, just occured to me. is:

p <<-EOS
this
EOS

appending to p or setting p? i’ve always though it was setting it, but the <<
dosen’t really indicate that does it? well, guess i’ll check…

···

On Tuesday 14 January 2003 12:40 pm, Tom Sawyer wrote:


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.’’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:’.:::. | ’ ‘’ * ‘.’/.’ (/’.’:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
’…’ ‘:::’ === * /\ * .’/.’. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-’| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /"\ | '-."". ‘-’ ‘-.’ '` |.

Paul Brannan pbrannan@atdesk.com writes:

[…]

I like the idea of being able to indent my here documents. I’m not
convinced that the proposed solution is the best solution, though.

Note that the perl community has already given this problem much
thought:
http://dev.perl.org/rfc/162.html

From what I can gather, the proposed perl solution would look like
this in Ruby:

p <<<EOS
foo
bar
EOS
#=> " foo\n bar\n"

(that is, strip any leading whitespace that is indented the same as
the terminator).

I do not like this simply because it introduces a problem of tabs -vs-
spaces.

···

On Wed, Jan 15, 2003 at 02:31:22AM +0900, Kazuo Saito 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

Is this the purpose of this feature? Or am I missing something?

Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

···

On Wed, 15 Jan 2003, Gavin Sinclair wrote:

then again wouldn’t something like this be simpler:

p <<| foo
> bar

puts p

and that’s it, such that the string is completed by the fact that there is
no /^\s*|/ match on the 3rd line. just thinking aloud here.

as you can see, i’m right with Dave on this. another vote +1.

as for all the here document functionality that Hal pointed out, as he says
himself, he dosen’t use it. and i doubt anyone does. it’s simply too
confusing. but GIVE ME THE ABOVE AND IT WILL BE ALL I USE! currently i
generally just use %Q{…} instead of here docs.

p %Q{
foo
bar
}

which makes me think of this possibility:

p %| foo

···

On Tuesday 14 January 2003 12:40 pm, Tom Sawyer wrote:
> bar


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.

DUH!!! SCRATCH THAT. THAT’S p AS IN PRINT. SORRY. SILLY << CONFUSED ME.

···

On Tuesday 14 January 2003 12:45 pm, Tom Sawyer wrote:

On Tuesday 14 January 2003 12:40 pm, Tom Sawyer wrote:

hey, just occured to me. is:

p <<-EOS
this
EOS

appending to p or setting p? i’ve always though it was setting it, but the
<< dosen’t really indicate that does it? well, guess i’ll check…


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.

And then there were those problematic passages
about “a python of great price” and “blessed
are the cheesemakers.”

Hal

“Wisdom is more precious than rubies.” - Proverbs

···

----- Original Message -----
From: “Joel VanderWerf” vjoel@PATH.Berkeley.EDU
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, January 14, 2003 1:28 PM
Subject: Re: ruby-dev summary 19198-19345

Paul Brannan wrote:

There’s something to be said for using the same syntax as perl6, since
it will make translation easier and reduce confusion.

I think a similar argument was made for not including certain books from
the Septuagint in the Christian Bible.

The books were not included because they didn’t use perl6 syntax? :wink:

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

···

On Wednesday, January 15, 2003, 12:36:43 PM, Daniel wrote:

On Wed, 15 Jan 2003, Gavin Sinclair wrote:

Hi,

···

In message “Re: ruby-dev summary 19198-19345” on 03/01/15, Paul Brannan pbrannan@atdesk.com writes:

Note that the perl community has already given this problem much
thought:
http://dev.perl.org/rfc/162.html

In message “Re: ruby-dev summary 19198-19345” on 03/01/15, Matt Armstrong 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.

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:
[…]
Is this the purpose of this feature? Or am I missing something?

It may help in unpacking Yaml-like things as well, but that is a guess:
suck in the text to unpack, build a p <<-| around it, and eval…

    Hugh
···

On Wed, 15 Jan 2003, Daniel Carrera wrote:

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.

Gavin

···

On Thursday, January 16, 2003, 3:19:13 PM, Tom wrote:

currently i generally just use %Q{…} instead of here docs.

p %Q{
foo
bar
}

as for all the here document functionality that Hal pointed out, as he
says
himself, he dosen’t use it. and i doubt anyone does. it’s simply too
confusing.

Hmm, I think that was someone else.

Hal

···

----- Original Message -----
From: “Tom Sawyer” transami@transami.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, January 15, 2003 10:19 PM
Subject: Re: ruby-dev summary 19198-19345

Note that this prints “\nfoo\n bar\n” instead of “foo\n bar\n” like
the original example would do.

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, and it can get confusing trying to remember which
characters you are and are not allowed to use inside your string. Since
here documents are terminated by a particular line instead of by a
particular character, they do not have this problem.

Paul

···

On Thu, Jan 16, 2003 at 01:19:13PM +0900, Tom Sawyer wrote:

p %Q{
foo
bar
}

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

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

···

In message “Re: ruby-dev summary 19198-19345” > on 03/01/15, Matt Armstrong 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.

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.

Really, I would be happiest if ruby-mode.el just set the indentation
to column 0 for <<EOF (and did not for <<-EOF). Then I would have no
use for this feature. :wink: