[#45382] [ruby-trunk - Feature #6530][Open] Improve Racc documentation coverage — "zzak (Zachary Scott)" <zachary@...>
5 messages
2012/06/02
[#45431] [ruby-trunk - Bug #6548][Open] Rake doesn't ignore arguments after -- — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>
12 messages
2012/06/05
[#45442] 1.8.7 to come this month — Urabe Shyouhei <shyouhei@...>
Hello. As I wrote before I will release a 1.8.7 patchlevel in this month.
5 messages
2012/06/06
[#45474] [ANN] Request for "slide-show" of your feature proposal — Yusuke Endoh <mame@...>
(Japanese later; 日本語が後にあります)
18 messages
2012/06/07
[#45483] Re: [ANN] Request for "slide-show" of your feature proposal
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2012/06/07
Is this what you were talking about?
[#46009] Re: [ANN] Request for "slide-show" of your feature proposal
— Aaron Patterson <tenderlove@...>
2012/06/30
On Thu, Jun 07, 2012 at 11:59:12PM +0900, Yusuke Endoh wrote:
[#46332] Re: [ANN] Request for "slide-show" of your feature proposal
— Roger Pack <rogerdpack2@...>
2012/07/11
> * at most THREE proposals per person
[#45552] [ruby-trunk - Bug #6571][Assigned] Time.mktime Y2K38 problem on 1.9.3p125 i386-mingw32 — "MartinBosslet (Martin Bosslet)" <Martin.Bosslet@...>
10 messages
2012/06/10
[#45563] [ruby-trunk - Bug #6573][Open] Webrick test failures — "bkabrda (Bohuslav Kabrda)" <bkabrda@...>
19 messages
2012/06/11
[#45589] Developers' meeting (7/21) — Yusuke Endoh <mame@...>
Hello, committers
10 messages
2012/06/12
[#45623] Re: Developers' meeting (7/21)
— Yusuke Endoh <mame@...>
2012/06/13
Four seats are now left.
[#45647] [ruby-trunk - Bug #6592][Open] test_call_double(DL::TestDL) fails on ARM HardFP — "vo.x (Vit Ondruch)" <v.ondruch@...>
15 messages
2012/06/14
[#45664] [ruby-trunk - Bug #6596][Open] New method for Arrays : Array#index — "robin850 (Robin Dupret)" <robin.dupret@...>
20 messages
2012/06/15
[#45694] [ruby-trunk - Feature #6602][Open] Tail call optimization: enable by default? — "ko1 (Koichi Sasada)" <redmine@...>
12 messages
2012/06/18
[#45715] [ruby-trunk - Feature #6609][Open] Toplevel as self extended module — "trans (Thomas Sawyer)" <transfire@...>
17 messages
2012/06/19
[#45732] [ruby-trunk - Bug #6614][Open] GC doesn't collect objects bound to (collectable) proc — "rogerdpack (Roger Pack)" <rogerpack2005@...>
9 messages
2012/06/20
[#45735] [ruby-trunk - Bug #6616][Open] MinGW: cannot build extensions or run tests due changes in exec_arg? — "luislavena (Luis Lavena)" <luislavena@...>
9 messages
2012/06/21
[#45749] [ruby-trunk - Bug #6616] MinGW: cannot build extensions or run tests due changes in exec_arg?
— "phasis68 (Heesob Park)" <phasis@...>
2012/06/21
[#45785] How can I contribute? — David Albert <davidbalbert@...>
Hello ruby-core,
6 messages
2012/06/22
[#45798] [ruby-trunk - Bug #6634][Open] Deadlock with join and ConditionVariable — "meh. (meh. I don't care)" <meh@...>
20 messages
2012/06/23
[#45805] [ruby-trunk - Feature #6636][Open] Enumerable#size — "marcandre (Marc-Andre Lafortune)" <ruby-core@...>
15 messages
2012/06/23
[#45822] [ruby-trunk - Feature #6641][Open] Hash.auto constructor — "trans (Thomas Sawyer)" <transfire@...>
9 messages
2012/06/25
[#45864] [ruby-trunk - Bug #6647][Open] Exceptions raised in threads should be logged — "headius (Charles Nutter)" <headius@...>
71 messages
2012/06/25
[#45866] [ruby-trunk - Bug #6647] Exceptions raised in threads should be logged
— "rue (Eero Saynatkari)" <redmine@...>
2012/06/25
[#45878] [ruby-trunk - Feature #6649][Open] Add new set_trace_func events "b-call", "b-return" — "ko1 (Koichi Sasada)" <redmine@...>
8 messages
2012/06/26
[#45887] [ruby-trunk - Bug #6650][Open] Fixing win32ole test errors — bosko (Boško Ivanišević) <bosko.ivanisevic@...>
10 messages
2012/06/26
[#45916] [ruby-trunk - Bug #6656][Open] Time#strftime('%Z') should return 'UTC' instead of 'GMT' — "stomar (Marcus Stollsteimer)" <redmine@...>
6 messages
2012/06/27
[#45922] Re: [ruby-trunk - Bug #6656][Open] Time#strftime('%Z') should return 'UTC' instead of 'GMT'
— Tanaka Akira <akr@...>
2012/06/28
2012/6/27 stomar (Marcus Stollsteimer) <[email protected]>:
[#45935] Re: [ruby-trunk - Bug #6656][Open] Time#strftime('%Z') should return 'UTC' instead of 'GMT'
— Marcus Stollsteimer <sto.mar@...>
2012/06/28
Am 28.06.2012 02:29, schrieb Tanaka Akira:
[#45940] Re: [ruby-trunk - Bug #6656][Open] Time#strftime('%Z') should return 'UTC' instead of 'GMT'
— Tanaka Akira <akr@...>
2012/06/28
2012/6/28 Marcus Stollsteimer <[email protected]>:
[#45925] Commit bit in GitHub mirror? — Luis Lavena <luislavena@...>
Hello,
6 messages
2012/06/28
[#45926] Re: Commit bit in GitHub mirror?
— Urabe Shyouhei <shyouhei@...>
2012/06/28
Hello, this is svn -> git gateway admin.
[#45958] [ruby-trunk - Feature #6668][Open] Multiple assignment should not return an Array object — "headius (Charles Nutter)" <headius@...>
7 messages
2012/06/29
[#47584] [ruby-trunk - Feature #6668] Multiple assignment should not return an Array object
— "headius (Charles Nutter)" <headius@...>
2012/09/19
[#45960] [ruby-trunk - Feature #6669][Open] A method like Hash#map but returns hash — "yhara (Yutaka HARA)" <redmine@...>
18 messages
2012/06/29
[#45983] [ruby-trunk - Bug #6675][Open] Raise exception when convert encoding of a character from GBK to UTF — "mghomn (Justin Peal)" <yujianbin@...>
5 messages
2012/06/30
[#46020] [ruby-trunk - Feature #6678][Open] Precedence of ^ operator — "trans (Thomas Sawyer)" <transfire@...>
6 messages
2012/06/30
[#46021] [ruby-trunk - Feature #6679][Open] Default Ruby source file encoding to utf-8 — "claytrump (Clay Trump)" <clay.trump@...>
21 messages
2012/06/30
[#46080] [ruby-trunk - Feature #6679][Assigned] Default Ruby source file encoding to utf-8
— "mame (Yusuke Endoh)" <mame@...>
2012/07/01
[#46653] [ruby-trunk - Feature #6679] Default Ruby source file encoding to utf-8
— "mame (Yusuke Endoh)" <mame@...>
2012/07/23
[ruby-core:45695] [ruby-trunk - Feature #6602] Tail call optimization: enable by default?
From:
"nobu (Nobuyoshi Nakada)" <nobu@...>
Date:
2012-06-18 09:10:59 UTC
List:
ruby-core #45695
Issue #6602 has been updated by nobu (Nobuyoshi Nakada).
Description updated
----------------------------------------
Feature #6602: Tail call optimization: enable by default?
https://bugs.ruby-lang.org/issues/6602#change-27287
Author: ko1 (Koichi Sasada)
Status: Open
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category: core
Target version: 2.0.0
=begin
Hi,
Some hours ago, Matz proposed turning on "tail call optimization" by default from Ruby 2.0.
What do you think about it?
= Background
Tail call: Method invocation at last of method body.
Tail call optimization: Eliminating the new stack frame creation when method invocation is "tail call".
For exmaple, the method bar() is located at last of method foo(), so bar() is "tail call".
def foo()
...
bar()
end
In this case, after invocation of method bar(), foo()'s method frame information (which contains local variables, program counter, stack pointer and so on) is no longer needed because method foo() doesn't work after that (correctly, method foo() only does "return").
Next example, a simple recursion code by foo(). Of course, foo() is "tail call".
def foo()
...
foo()
end
Current Ruby causes stack overflow error because such recursion consumes the (VM) stack. However, using tail call optimization, VM doesn't consume stack frame any more.
Such recursion can be converted to simple loop:
def foo
while true
foo()
end
end
Someone calls tail-call opt as "tail recursion optimization" because recursion is famous use-case (*1).
*1: Generally, tail-recursion optimization includes another optimization technique - "call" to "jump" translation. In my opinion, it is difficult to apply this optimization because recognizing "recursion" is difficult in Ruby's world.
Next example. fact() method invocation in "else" clause is *not* a "tail call".
def fact(n)
if n < 2
1
else
n * fact(n-1)
end
end
If you want to use tail-call optimization on fact() method, you need to change fact() method as follows (continuation passing style).
def fact(n, r)
if n < 2
r
else
fact(n-1, n*r)
end
end
In this case, fact() is tail-call (and a bit difficult to read/write).
Of course, the following code is easy to understand and short.
(1..n).inject(:*)
Last examples. Recognizing tail-call is a bit difficult.
def foo
begin
bar2() # not a tail-call
rescue
bar3() # not a tail-call
rescue
bar4() # not a tail-call
ensure
bar5() # tail-call!
end
end
def foo
while true
return bar("break") # tail-call? (current CRuby can't handle "break" in eval().
end
end
CRuby 1.9 has a code tail-call optimization (not tested yet. maybe there are several bugs). However, it is off by default because of several problems described in next section.
= Problems:
* (1) backtrace: Eliminating method frame means eliminating backtrace.
* (2) set_trace_func(): It is difficult to probe "return" event for tail-call methods.
* (3) semantics: It is difficult to define tail-call in document (half is joking, but half is serious)
References:
* [ruby-core:20273]
* [ruby-core:20307]
* [ruby-core:22736]
* [ruby-core:22790]
Maybe (1) has big impact for ordinal users.
For example:
def foo
bar()
end
def bar
baz()
end
def baz
raise("somethig error")
end
In this case, backtrace information only include "baz", because bar() in foo and baz() in bar are "tail-call". Users can't see eliminated frame information in backtrace.
This is why we don't introduce them by default to Ruby 1.9.
= Discussion
Many people ask us that "why don't you introduce tail-call optimization? it is very easy technique." I wrote reasons above.
Matz said "it seems small impact enough. Go ahead". (I doubt it ;P )
Yusuke Endo proposed that introducing special form (for example, send_tail(:foo, ...)) to declare tail call. Users only use this special form when the backtrace information can be eliminated (*2).
(*2) Special form "goto foo()" is nice joking feature :) I like it but I believe Matz will reject it.
Akira Tanaka introduced that special backtrace notation like:
baz
... (eliminated by tail call optimization)
main
to represent eliminating method invocation information. We can know they were eliminated (good) but we can't know what method frames were eliminated (bad).
= Conclusion
Matz wanted to introduce it. However it has several problems. Should we turn on this optimization by default?
Sorry for long (and poor English) article. Comments and proposals are welcome (with short English, long Ruby codes ;p).
Thanks,
Koichi
=end
--
http://bugs.ruby-lang.org/