[ruby-core:94710] [Ruby master Feature#12543] explicit tail call syntax: foo() then return
From:
ko1@...
Date:
2019-09-02 03:29:49 UTC
List:
ruby-core #94710
Issue #12543 has been updated by ko1 (Koichi Sasada). Status changed from Closed to Assigned Another idea: `tailcall return foo()` * Background: `return` is void expression and any `method(return)` is not prohibited on current compiler. So nobody use it == no-incompatibility. Any keywords are acceptable (example: `goto return foo()`). ---- I like Endoh-san's original idea, tailcall explicitly. It is similar to goto, and programmer should understand there is no backtrace. I heard that someone want to use taicall with pattern matching which will be introduced into Ruby 2.7. ---------------------------------------- Feature #12543: explicit tail call syntax: foo() then return https://bugs.ruby-lang.org/issues/12543#change-81320 * 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>