[ruby-core:94778] [Ruby master Feature#12543] explicit tail call syntax: foo() then return
From:
daniel@...42.com
Date:
2019-09-04 14:54:09 UTC
List:
ruby-core #94778
Issue #12543 has been updated by Dan0042 (Daniel DeLorme). Questions: 1. Is it possible to use "partial" tail-call optimization, where the backtrace is kept but all other frame state is discarded? 2. Is it possible to detect tail-recursion and turn on optimization just for that? ---------------------------------------- Feature #12543: explicit tail call syntax: foo() then return https://bugs.ruby-lang.org/issues/12543#change-81396 * Author: mame (Yusuke Endoh) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- 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> ---Files-------------------------------- then_return.patch (9.18 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>