[#83096] File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?}) — Nobuyoshi Nakada <nobu@...>
On 2017/10/04 8:47, normal@ruby-lang.org wrote:
5 messages
2017/10/04
[#83100] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Eric Wong <normalperson@...>
2017/10/04
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#83105] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Nobuyoshi Nakada <nobu@...>
2017/10/04
On 2017/10/04 15:55, Eric Wong wrote:
[#83107] Alias Enumerable#include? to Enumerable#includes? — Alberto Almagro <albertoalmagro@...>
Hello,
9 messages
2017/10/04
[#83113] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/05
This has been requested countless times, then rejected each and every time.
[#83129] Re: Alias Enumerable#include? to Enumerable#includes?
— Alberto Almagro <albertoalmagro@...>
2017/10/05
Sorry I didn't found it on the core mail list's archive.
[#83138] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/06
Ruby has not been made of popular votes so far. You have to show us
[#83149] Re: Alias Enumerable#include? to Enumerable#includes?
— Eric Wong <normalperson@...>
2017/10/06
Alberto Almagro <albertoalmagro@gmail.com> wrote:
[#83200] [Ruby trunk Feature#13996] [PATCH] file.c: apply2files releases GVL — normalperson@...
Issue #13996 has been reported by normalperson (Eric Wong).
4 messages
2017/10/10
[ruby-core:83152] [Ruby trunk Feature#12115] Add Symbol#call to allow to_proc shorthand with arguments
From:
knu@...
Date:
2017-10-06 08:09:03 UTC
List:
ruby-core #83152
Issue #12115 has been updated by knu (Akinori MUSHA).
I think `&[symbol, *args]` can be a natural extension to `&symbol`, as they are both a shorthand for `{ |_| _.__send__(*object) }`.
For Array to provide #to_proc would be just a little bit weird convention for greater convenience, just as Symbol#to_proc is. Symbol had been in no way a function-like entity, but once Symbol#to_proc was added we almost instantly grew used to it and now we all take it for granted because being able to `map(&:to_s)` is so handy and useful.
The original proposal that is to introduce a new syntax is a bit too costly for one of the most frequently wanted features like this because it takes years of time before everyone can start using it. On the other hand, adding Array#to_proc is easily backportable and you can start using it today. FWIW, Matz once said he was not in favor of extending the syntax just for this: http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/45404?45384-45592 (written in Japanese, try Google translate)
I've done some more googling and it turned out that Array#to_proc was not a new idea at all.
- https://www.sanityinc.com/articles/adding-array-to-proc-to-ruby/
- http://t.y13i.com/post/83319234720/ruby-%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E6%9B%B8%E3%81%8D%E3%81%9F%E3%81%8F%E3%81%AA%E3%81%84%E7%97%85%E3%81%AB%E7%BD%B9%E6%82%A3%E3%81%97%E3%81%A6arraytoproc%E3%82%92%E5%AE%9A%E7%BE%A9%E3%81%97%E3%81%A6%E3%81%BF%E3%81%9F (written in Japanese)
- http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/45404?45384-45592 (written in Japanese)
- https://stackoverflow.com/a/5702174 (J旦rg, I found you there!)
So, these people independently have reached the same idea! Isn't that a good sign?
----------------------------------------
Feature #12115: Add Symbol#call to allow to_proc shorthand with arguments
https://bugs.ruby-lang.org/issues/12115#change-67090
* Author: felixbuenemann (Felix B端nemann)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I am a great fan of the `Symbol#to_proc` shorthand when mapping or reducing collections:
```ruby
[1,2,16].map(&:to_s)
=> ["1", "2", "16"]
[1,2,16].reduce(&:*)
=> 32
```
I often wish it would be possible to pass an argument to the method when doing this, which currently requires a block and is more verbose:
```ruby
[1,2,16].map { |n| n.to_s(16) }
=> ["1", "2", "10"]
# active_support example
{id: 1, parent_id: nil}.as_json.transform_keys { |k| k.camelize :lower }.to_json
=> '{"id":1,"parentId":null}'
```
It would be much shorter, if ruby allowed this:
```ruby
[1,2,16].map(&:to_s.(16))
=> ["1", "2", "10"]
# active_support example
{id: 1, parent_id: nil}.as_json.transform_keys(&:camelize.(:lower)).to_json
=> '{"id":1,"parentId":null}'
```
This can be implemented easily, by adding the `Symbol#call` method:
```ruby
class Symbol
def call(*args, &block)
->(caller, *rest) { caller.send(self, *rest, *args, &block) }
end
end
```
*Source*: [stackoverflow: Can you supply arguments to the map(&:method) syntax in Ruby?](http://stackoverflow.com/questions/23695653/can-you-supply-arguments-to-the-mapmethod-syntax-in-ruby)
**I think this is a rather common use case, so I propose to add `Symbol#call` to the Ruby standard library.**
--
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>