Ask a Question related to Ruby, Design and Development.
-
Takaaki Tateishi #1
ruby-dev summary 21637-21729
Hello,
I present you a summary of the ruby-dev mailing list.
[ruby-dev:21639] load() blocks thread scheduling
Tietew posted the following scripts which didn't timeout and didn't
accept Ctrl+C.
-- main.rb --
require 'timeout'
timeout(60) { load 'block.rb' }
--- block.rb
loop { }
He also posted a patch to change the thread. Matz wrote that
it would cause unexpected troubles if we didn't block other
thread while loading a script.
[ruby-dev:21641] SOAP::StreamError: Illegal media type
SOAP4R's test suite failed since it required pre-installed SOAP4R
library. Matz suggested that the test suite in ruby should use
not pre-installed libraries but use archived new libraries from
the archive.
[ruby-dev:21678] Problems of testing test/drb on Windows
U. Nakamura showed two opinions about test/drb on Windows as follows.
(a) test/drb/test_drbunix.rb failed if it was executed via
test/runner.rb, since Windows didn't have Socket::UNIX*.
He thought that such error had better occur when loading
'drb/unix'.
(b) The result of test/drb/test_acl.rb was 'E', since the
ruby was compiled without AF_INET6 and IPAddr#ipv6?
caused NameError. He proposed some solutions to avoid
NameError.
[ruby-dev:21679] Proposal: string literal concatenation
Mput proposed a specification which enables us to concatenate
strings using a new line like the following script.
s = "foo1" "bar1"
"foo2" "bar2"
Matz answered that he will discard string literal concatenation.
[ruby-dev:21682] ruby-tk hangs when exception is raised
Akira Yamada received a bug report as a package maintainer of
Debian. The following Ruby/TK script caused a problem that
Ctrl+C was not available. This problem have not been solved yet.
require 'tk'
r = TkRoot.new
b = TkButton.new(r) { text "break me" }
b.command proc {
raise "error!"
}
b.pack
Tk.mainloop
--
Takaaki Tateishi <ttate@ttsky.net>
Takaaki Tateishi Guest
-
ruby-dev summary 21833-21882
Hello, This is a summary of ruby-dev mailing list last week. lib/test/unit/ui/tk/testrunner.rb A new GUI interface for lib/test/unit... -
[ANN] ruby-dev summary index
Hi all, I made the index page of ruby-dev summary: http://i.loveruby.net/en/ruby-dev-summary.html This page is going to be updated on every... -
ruby-dev summary 21531-21607
Hello all, This is a summary of ruby-dev mailing list. O_ACCMODE Tanaka Akira added a constant Fcntl::O_ACCMODE defined in POSIX fcntl.h... -
ruby-dev summary 21295-21366
Hi all, This is a summary of ruby-dev ML in these days. test and sample directory NAKAMURA Hiroshi suggested to locate tests and examples... -
ruby-dev summary 20519-20714
Hello, all. Recently, I'm working on BigDecimal. My main purpose is not to extend it, but to be become friendly with other numerical classes. ... -
Paul Brannan #2
Re: ruby-dev summary 21637-21729
On Fri, Oct 31, 2003 at 07:01:28AM +0900, Takaaki Tateishi wrote:
So what will the result of the above two lines of code be?> [ruby-dev:21679] Proposal: string literal concatenation
> Mput proposed a specification which enables us to concatenate
> strings using a new line like the following script.
>
> s = "foo1" "bar1"
> "foo2" "bar2"
>
> Matz answered that he will discard string literal concatenation.
Paul
Paul Brannan Guest
-
Yukihiro Matsumoto #3
Re: ruby-dev summary 21637-21729
Hi,
In message "Re: ruby-dev summary 21637-21729"
on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
|On Fri, Oct 31, 2003 at 07:01:28AM +0900, Takaaki Tateishi wrote:
|> [ruby-dev:21679] Proposal: string literal concatenation
|> Mput proposed a specification which enables us to concatenate
|> strings using a new line like the following script.
|>
|> s = "foo1" "bar1"
|> "foo2" "bar2"
|>
|> Matz answered that he will discard string literal concatenation.
|
|So what will the result of the above two lines of code be?
Plain syntax error in 1.9.x.
matz.
Yukihiro Matsumoto Guest
-
Paul Brannan #4
Re: ruby-dev summary 21637-21729
On Thu, Nov 06, 2003 at 11:17:59PM +0900, Yukihiro Matsumoto wrote:
Is the syntax error because of the first line or because of the second?> In message "Re: ruby-dev summary 21637-21729"
> on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
> |So what will the result of the above two lines of code be?
>
> Plain syntax error in 1.9.x.
I ask because I do this a lot in my code:
s = "this is a string " \
"that I have chosen to break " \
"into multiple lines
I would be happy to switch to using heredocs if there were an easy way
to indent heredocs.
Paul
Paul Brannan Guest
-
Yukihiro Matsumoto #5
Re: ruby-dev summary 21637-21729
Hi,
In message "Re: ruby-dev summary 21637-21729"
on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
|Is the syntax error because of the first line or because of the second?
Both. Sequence of strings will no longer be valid.
|I ask because I do this a lot in my code:
|
| s = "this is a string " \
| "that I have chosen to break " \
| "into multiple lines"
How about
s = "this is a string " +
"that I have chosen to break " +
"into multiple lines"
?
matz.
Yukihiro Matsumoto Guest
-
Paul Brannan #6
Re: ruby-dev summary 21637-21729
On Fri, Nov 07, 2003 at 12:36:23AM +0900, Yukihiro Matsumoto wrote:
This works, but the concatenation is done at run-time instead of at> In message "Re: ruby-dev summary 21637-21729"
> on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
> |
> | s = "this is a string " \
> | "that I have chosen to break " \
> | "into multiple lines"
>
> How about
>
> s = "this is a string " +
> "that I have chosen to break " +
> "into multiple lines"
compile-time.
Paul
Paul Brannan Guest
-
Robert Church #7
Re: ruby-dev summary 21637-21729
On Fri, Nov 07, 2003 at 07:57:32AM +0900, Paul Brannan quipped:
Or so you assume. I don't know how Matz will handle this, but there's>> > How about
> >
> > s = "this is a string " +
> > "that I have chosen to break " +
> > "into multiple lines"
> This works, but the concatenation is done at run-time instead of at
> compile-time.
no reason concatenation of string constants could not be done at
compile time.
Robert Church Guest
-
Eric Hodel #8
Re: ruby-dev summary 21637-21729
--9Q2l3mYpK16UQ/iv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Robert Church (rc@pgdn.org) wrote:
You can redefine String#+, so no such optimization must be made at> On Fri, Nov 07, 2003 at 07:57:32AM +0900, Paul Brannan quipped:>=20> >=20> > > How about
> > >=20
> > > s =3D "this is a string " +
> > > "that I have chosen to break " +
> > > "into multiple lines"
> > This works, but the concatenation is done at run-time instead of at
> > compile-time.
> Or so you assume. I don't know how Matz will handle this, but there's
> no reason concatenation of string constants could not be done at
> compile time.
compile time.
--=20
Eric Hodel - [email]drbrain@segment7.net[/email] - [url]http://segment7.net[/url]
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
--9Q2l3mYpK16UQ/iv
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)
iD8DBQE/qtVWMypVHHlsnwQRAtPlAJ9DCuzf1TwhCsALULpNe8/BK3PC/gCcCjhw
gBjJP9ZU9QLi6bD30tO9TgA=
=LqSQ
-----END PGP SIGNATURE-----
--9Q2l3mYpK16UQ/iv--
Eric Hodel Guest
-
gabriele renzi #9
Re: ruby-dev summary 21637-21729
il Fri, 7 Nov 2003 07:57:32 +0900, Paul Brannan <pbrannan@atdesk.com>
ha scritto::
well, this could be meaningful if ruby had a real compiling fase.>This works, but the concatenation is done at run-time instead of at
>compile-time.
And if it had it this could be esailt solved from the compiler (I
think javac does this, for example)
gabriele renzi Guest
-
Sean O'Dell #10
Re: ruby-dev summary 21637-21729
On Thursday 06 November 2003 07:36 am, Yukihiro Matsumoto wrote:
My 1 cent: I really wish "" \ style concatenation wouldn't go away.> Hi,
>
> In message "Re: ruby-dev summary 21637-21729"
>
> on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
> |Is the syntax error because of the first line or because of the second?
>
> Both. Sequence of strings will no longer be valid.
>
> |I ask because I do this a lot in my code:
> |
> | s = "this is a string " \
> | "that I have chosen to break " \
> | "into multiple lines"
>
> How about
>
> s = "this is a string " +
> "that I have chosen to break " +
> "into multiple lines"
> ?
Sean O'Dell
Sean O'Dell Guest
-
nobu.nokada@softhome.net #11
Re: ruby-dev summary 21637-21729
Hi,
At Fri, 7 Nov 2003 07:57:32 +0900,
Paul Brannan wrote:In 1.8, this is concatenated at compile-time. :)> On Fri, Nov 07, 2003 at 12:36:23AM +0900, Yukihiro Matsumoto wrote:>> > In message "Re: ruby-dev summary 21637-21729"
> > on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
> > |
> > | s = "this is a string " \
> > | "that I have chosen to break " \
> > | "into multiple lines"
> >
> > How about
> >
> > s = "this is a string " +
> > "that I have chosen to break " +
> > "into multiple lines"
> This works, but the concatenation is done at run-time instead of at
> compile-time.
s = "this is a string #{ # And you can write
""}that I have chosen to break #{ # comments!
""}into multiple lines"
--
Nobu Nakada
nobu.nokada@softhome.net Guest
-
Joel VanderWerf #12
Re: ruby-dev summary 21637-21729
[email]nobu.nokada@softhome.net[/email] wrote:
Very cool! It doesn't need the "", though, does it?> In 1.8, this is concatenated at compile-time. :)
>
> s = "this is a string #{ # And you can write
> ""}that I have chosen to break #{ # comments!
> ""}into multiple lines"
>
irb(main):001:0> "foo#{
irb(main):002:0" }bar"
=> "foobar"
Joel VanderWerf Guest
-
nobu.nokada@softhome.net #13
Re: ruby-dev summary 21637-21729
Hi,
At Fri, 7 Nov 2003 10:42:51 +0900,
Joel VanderWerf wrote:It needs for compile-time concatenation, because nil.to_s might>> > In 1.8, this is concatenated at compile-time. :)
> >
> > s = "this is a string #{ # And you can write
> > ""}that I have chosen to break #{ # comments!
> > ""}into multiple lines"
> >
> Very cool! It doesn't need the "", though, does it?
>
> irb(main):001:0> "foo#{
> irb(main):002:0" }bar"
> => "foobar"
be replaced.
$ ruby -rNodeDump -e '"foo#{' -e '}bar"'
NodeDump V0.9
NODE_NEWLINE: [-e:1]
NODE_DSTR: "foo"
NODE_EVSTR:
NODE_STR: "bar"
$ ruby -rNodeDump -e '"foo#{' -e '""}bar"'
NodeDump V0.9
NODE_NEWLINE: [-e:1]
NODE_STR: "foobar"
This optimization is limited to the case #{} ends with a
literal string (and preceding literals without any side
effects)
--
Nobu Nakada
nobu.nokada@softhome.net Guest
-
Yukihiro Matsumoto #14
Re: ruby-dev summary 21637-21729
Hi,
In message "Re: ruby-dev summary 21637-21729"
on 03/11/07, Paul Brannan <pbrannan@atdesk.com> writes:
|This works, but the concatenation is done at run-time instead of at
|compile-time.
Don't worry. It's done at run-time anyway.
matz.
Yukihiro Matsumoto Guest
-
Yukihiro Matsumoto #15
Re: ruby-dev summary 21637-21729
Hi,
In message "Re: ruby-dev summary 21637-21729"
on 03/11/07, "Sean O'Dell" <sean@celsoft.com> writes:
|My 1 cent: I really wish "" \ style concatenation wouldn't go away.
Why?
matz.
Yukihiro Matsumoto Guest
-
Laurent Sansonetti #16
Re: ruby-dev summary 21637-21729
Hi,
Yukihiro Matsumoto wrote:
I would prefer this:> Hi,
>
> In message "Re: ruby-dev summary 21637-21729"
> on 03/11/06, Paul Brannan <pbrannan@atdesk.com> writes:
>
> |Is the syntax error because of the first line or because of the second?
>
> Both. Sequence of strings will no longer be valid.
>
> |I ask because I do this a lot in my code:
> |
> | s = "this is a string " \
> | "that I have chosen to break " \
> | "into multiple lines"
>
> How about
>
> s = "this is a string " +
> "that I have chosen to break " +
> "into multiple lines"
s = "this is a string "
+ "that I have chosen to break "
+ "into multiple lines"
I think it's always better to avoid operators in the end of lines (code
is therefore more readeable).
Same think for this:
if ( expr1...
and expr2...
and expr3... )
# do something
end
But AFAIK && unfortunately, Ruby does not handle this kind of syntax yet.
Matz, what do you think about this?
Thanks,
--
Laurent
Laurent Sansonetti Guest
-
Tim Bates #17
Re: ruby-dev summary 21637-21729
On Fri, Nov 07, 2003 at 06:04:47PM +0900, Laurent Sansonetti wrote:
Because of Ruby's line-based syntax, Ruby guesses that if you have hit> I think it's always better to avoid operators in the end of lines (code
> is therefore more readeable).
>
> But AFAIK && unfortunately, Ruby does not handle this kind of syntax yet.
the end of the line and the line as a whole is valid, then you have
finished that statement. This is essentially a limitation of the parser.
There are two ways around this - require statements to end with a
special character (eg a semicolon) so that if we get to the end of the
line and haven't found that character yet we know the statement isn't
finished, or implement look-ahead in the parser to take a look at the
next line and see if it, when combined with the current line, is a valid
statement as a whole. This is a lot more difficult; it involves
look-ahead and creates a whole new family of ambiguities; e.g. what do
you do if the next line creates a valid statement when combined with
this line, and also the two lines are valid statements by themselves? So
if the alternative is to require every statement to end in a semicolon
(noooo!) which takes a significant chunk out of the beauty of the
language, I must say that I prefer the way it is done now - and the same
applies to most of Matz's decisions, which is why I love this language.
Tim Bates
--
[email]tim@bates.id.au[/email]
Tim Bates Guest
-
Yukihiro Matsumoto #18
Re: ruby-dev summary 21637-21729
In message "Re: ruby-dev summary 21637-21729"
on 03/11/07, Laurent Sansonetti <laurent@datarescue.be> writes:
|I would prefer this:
|
|s = "this is a string "
| + "that I have chosen to break "
| + "into multiple lines"
|
|I think it's always better to avoid operators in the end of lines (code
|is therefore more readeable).
|
|Same think for this:
|
|if ( expr1...
| and expr2...
| and expr3... )
|
| # do something
|end
|
|But AFAIK && unfortunately, Ruby does not handle this kind of syntax yet.
|
|Matz, what do you think about this?
There's always trade-off. Newline sensitive syntax do not allow
line concatenation by operator at the beginning of a line, e.g. how
can we distinguish
s = "this is a string "
+ "that I have chosen to break "
+ "into multiple lines"
which is a single assignment statement, from
s = "this is a string "
+ "that I have chosen to break "
+ "into multiple lines"
an assignment followed by two unary plus expression?
matz.
Yukihiro Matsumoto Guest
-
T. Onoma #19
Re: ruby-dev summary 21637-21729
> > | s = "this is a string " \
shades of %L and kin>> > | "that I have chosen to break " \
> > | "into multiple lines"
> >
> > How about
> >
> > s = "this is a string " +
> > "that I have chosen to break " +
> > "into multiple lines"
> I would prefer this:
>
> s = "this is a string "
> + "that I have chosen to break "
> + "into multiple lines"
T. Onoma Guest
-
T. Onoma #20
Re: ruby-dev summary 21637-21729
> > Both. Sequence of strings will no longer be valid.
how will this 'fect HERE docs?> >
> > |I ask because I do this a lot in my code:
> > |
> > | s = "this is a string " \
> > | "that I have chosen to break " \
> > | "into multiple lines"
print <<HERE
Double quoted \
here document.
HERE
T. Onoma Guest



Reply With Quote

