From: shevegen@... Date: 2020-04-01T01:25:47+00:00 Subject: [ruby-core:97653] [Ruby master Feature#16746] Endless method definition Issue #16746 has been updated by shevegen (Robert A. Heiler). > I'm paranoid that the ends end Ruby. I hope Ruby is endless. With so many cancellations of events this year, we may not want to want to jinx ruby too much for the 3.0 release this year because then 3.0 itself may become the endless version! (Or we could skip it, like PHP skipped a version ... I was briefly tempted to propose this on this special day today, but I really don't want to jinx it. I do, however had, remember matz joking last year about unforeseen events ... now I hope I just did not jinx it!) ---------------------------------------- Feature #16746: Endless method definition https://bugs.ruby-lang.org/issues/16746#change-84850 * Author: mame (Yusuke Endoh) * Status: Open * Priority: Normal ---------------------------------------- Ruby syntax is full of "end"s. I'm paranoid that the ends end Ruby. I hope Ruby is endless. So, I'd like to propose a new method definition syntax. ```ruby def: value(args) = expression ``` As you see, there is no "end". Examples. ```ruby def: hello(name) = puts("Hello, #{ name }") hello("endless Ruby") #=> Hello, endless Ruby ``` ```ruby def: inc(x) = x + 1 p inc(42) #=> 43 ``` ```ruby x = Object.new def: x.foo = "FOO" p x.foo #=> "FOO" ``` ```ruby def: fib(x) = x < 2 ? x : fib(x-1) + fib(x-2) p fib(10) #=> 55 ``` Limitations. * `def: foo x = x` is invalid; the parentheses for formal arguments are mandatory. * `private def: foo = x` is invalid; this method definition cannot be an method argument. A patch is attached. No conflicts. ---Files-------------------------------- endless-method-definition.patch (2.99 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: