Project

General

Profile

Feature #12543

explicit tail call syntax: foo() then return

Added by mame (Yusuke Endoh) 9 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:76235]

Description

How about introducing a new syntax for tail call?

def foo()
  foo()
end
foo() #=> stack level too deep
def bar()
  bar() then return
end
bar() #=> infinite loop
  • no new keyword (cf. goto foo())
  • no conflict with any existing syntax
  • an experimental patch is available (attached)
  • no shift/reduce nor reduce/reduce conflict in parse.y

--
Yusuke Endoh mame@ruby-lang.org

then_return.patch View (9.18 KB) mame (Yusuke Endoh), 07/02/2016 05:23 PM


Related issues

Related to Ruby trunk - Feature #6602: Tail call optimization: enable by default? Feedback

History

#1 [ruby-core:76236] Updated by mame (Yusuke Endoh) 9 months ago

  • Subject changed from explicit tal call syntax: foo() then return to explicit tail call syntax: foo() then return

#2 Updated by mame (Yusuke Endoh) 9 months ago

  • Related to Feature #6602: Tail call optimization: enable by default? added

#3 [ruby-core:76419] Updated by ko1 (Koichi Sasada) 8 months ago

mame-san:

Do you have use-cases?

#4 [ruby-core:76440] Updated by matz (Yukihiro Matsumoto) 8 months ago

  • Status changed from Open to Closed

I am not positive. This may not work under tracing. I am for adding tail-call optimization, but Koichi do not love the idea either.

Matz.

Also available in: Atom PDF