[#98621] Re: Function getlogin_r()'s protoype] — Bertram Scharpf <lists@...>
FYI,
3 messages
2020/06/02
[#98947] [Ruby master Feature#16986] Anonymous Struct literal — ko1@...
Issue #16986 has been reported by ko1 (Koichi Sasada).
66 messages
2020/06/26
[#98962] [Ruby master Bug#16988] Kernel.load loads file from current directory without '.' in path — misharinn@...
Issue #16988 has been reported by TheSmartnik (Nikita Misharin).
5 messages
2020/06/26
[#98969] [Ruby master Feature#16994] Sets: shorthand for frozen sets of symbols / strings — marcandre-ruby-core@...
Issue #16994 has been reported by marcandre (Marc-Andre Lafortune).
7 messages
2020/06/26
[#100117] [Ruby master Feature#16994] Sets: shorthand for frozen sets of symbols / strings
— matz@...
2020/09/25
Issue #16994 has been updated by matz (Yukihiro Matsumoto).
[ruby-core:98941] [Ruby master Feature#16746] Endless method definition
From:
eregontp@...
Date:
2020-06-25 21:36:37 UTC
List:
ruby-core #98941
Issue #16746 has been updated by Eregon (Benoit Daloze).
Noteworthy is the current syntax in trunk is `def name(*args) = expr` (and not `def: name`), so there is *no* visual cue that this is a endless method definition except the `=` which comes very late.
I agree with @marcandre, I think it makes code just less readable and harder to maintain.
----------------------------------------
Feature #16746: Endless method definition
https://bugs.ruby-lang.org/issues/16746#change-86315
* Author: mame (Yusuke Endoh)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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.47 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>