[#107008] [Ruby master Bug#18465] Make `IO#write` atomic. — "ioquatix (Samuel Williams)" <noreply@...>
Issue #18465 has been reported by ioquatix (Samuel Williams).
16 messages
2022/01/09
[#107150] [Ruby master Feature#18494] [RFC] ENV["RUBY_GC_..."]= changes GC parameters dynamically — "ko1 (Koichi Sasada)" <noreply@...>
Issue #18494 has been updated by ko1 (Koichi Sasada).
4 messages
2022/01/17
[#107170] Re: [Ruby master Feature#18494] [RFC] ENV["RUBY_GC_..."]= changes GC parameters dynamically
— Eric Wong <normalperson@...>
2022/01/17
> https://bugs.ruby-lang.org/issues/18494
[#107302] [Ruby master Bug#18553] Memory leak on compiling method call with kwargs — "ibylich (Ilya Bylich)" <noreply@...>
Issue #18553 has been reported by ibylich (Ilya Bylich).
4 messages
2022/01/27
[#107346] [Ruby master Misc#18557] DevMeeting-2022-02-17 — "mame (Yusuke Endoh)" <noreply@...>
Issue #18557 has been reported by mame (Yusuke Endoh).
18 messages
2022/01/29
[ruby-core:107004] [Ruby master Feature#12125] Proposal: Shorthand operator for Object#method
From:
"konsolebox (K B)" <noreply@...>
Date:
2022-01-07 18:23:46 UTC
List:
ruby-core #107004
Issue #12125 has been updated by konsolebox (K B).
Has `&&` been considered?
```
Dir["*/*.c"].map(&&File.basename)
```
It can also adapt to outside usage so `&File.basename` equals `File.method(:basename)`.
----------------------------------------
Feature #12125: Proposal: Shorthand operator for Object#method
https://bugs.ruby-lang.org/issues/12125#change-95836
* Author: Papierkorb (Stefan Merettig)
* Status: Open
* Priority: Normal
----------------------------------------
Hello,
The `&` operator lets one pass a `#call`-able object as block.
Really useful feature, but at the moment, if you want to pass a `Method` this way the syntax is not really concise:
```ruby
Dir["*/*.c"].map(&File.method(:basename))
```
More often than not, at least I end up writing this instead `.map{|a| File.basename a}` which isn't that great either.
Thus, I want to propose adding a short-hand operator to the ruby language, which simply calls `#method` on an `Object`.
It could look like this: `an_object->the_method` which is 100% equivalent to doing `an_object.method(:the_method)`
I'm reusing the `->` operator which is already used for the stabby lambda. But I think it makes sense: You have an object,
and from that object you point at a method to get it as `Method`.
With this, the example from above becomes: `Dir["*/*.c"].map(&File->basename)`
I attached a proof of concept patch. When you apply this to trunk, you can try the example above yourself.
Do note however that this PoC also breaks stabby lambda for the moment. I'll work on fixing that the following
days.
Thank you for reading,
Stefan.
---Files--------------------------------
method_shorthand.diff (740 Bytes)
dot-symbol.patch (554 Bytes)
--
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>