ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:50384] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
       [not found] <redmine.issue-14223.20171222164605@ruby-lang.org>
@ 2017-12-22 16:46 ` manga.osyo
  2017-12-26  8:39 ` [ruby-dev:50395] " nobu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: manga.osyo @ 2017-12-22 16:46 UTC (permalink / raw)
  To: ruby-dev

Issue #14223 has been reported by osyo (manga osyo).

----------------------------------------
Feature #14223: Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
https://bugs.ruby-lang.org/issues/14223

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Refinements に関する提案です。  
現行の仕様では Refinements で定義された `#to_proc` は `&hoge` 時に暗黙的に呼びだされません。  

```ruby
class X
end

using Module.new {
	refine String do
		def to_proc
			proc { |it| it.send self }
		end

		def refine_method
			"X#refine_method"
		end
	end
}

def func &block
end

p "upcase".refine_method
# => "X#refine_method"

p "upcase".to_proc.call "homu"
# => "HOMU"

# Error: wrong argument type X (expected Proc) (TypeError)
func &"upcase"
```

実行結果:https://wandbox.org/permlink/sbvsCeXwXzwp1WxA


最近の傾向として `Kernel#send` や式展開時の `#to_s` などで Refinements が有効になっています。
そういう意味では `&hoge` で暗黙的に呼び出される `#to_proc` も Refinements が有効になってもよいのではないでしょうか。  
この件に関して、他の方の意見を聞かせていただけると助かります。  
また、自分で実装を書いてみたのですが『とりあえず動いている』というレベルなので、Refinements の実装に詳しい方がいればパッチもみていただけると助かります。  


---Files--------------------------------
refinemetns_to_proc.patch (3.73 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50395] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
       [not found] <redmine.issue-14223.20171222164605@ruby-lang.org>
  2017-12-22 16:46 ` [ruby-dev:50384] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案 manga.osyo
@ 2017-12-26  8:39 ` nobu
  2017-12-29  6:47 ` [ruby-dev:50405] " manga.osyo
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: nobu @ 2017-12-26  8:39 UTC (permalink / raw)
  To: ruby-dev

Issue #14223 has been updated by nobu (Nobuyoshi Nakada).


賛成です。

できれば不要なインデントの変更などは混ぜないでください。

----------------------------------------
Feature #14223: Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
https://bugs.ruby-lang.org/issues/14223#change-68973

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Refinements に関する提案です。  
現行の仕様では Refinements で定義された `#to_proc` は `&hoge` 時に暗黙的に呼びだされません。  

```ruby
using Module.new {
	refine String do
		def to_proc
			proc { |it| it.send self }
		end

		def refine_method
			"X#refine_method"
		end
	end
}

def func &block
end

p "upcase".refine_method
# => "X#refine_method"

p "upcase".to_proc.call "homu"
# => "HOMU"

# Error: wrong argument type X (expected Proc) (TypeError)
func &"upcase"
```

実行結果:https://wandbox.org/permlink/j8Hhavy7LoKYjrnz


最近の傾向として `Kernel#send` や式展開時の `#to_s` などで Refinements が有効になっています。
そういう意味では `&hoge` で暗黙的に呼び出される `#to_proc` も Refinements が有効になってもよいのではないでしょうか。  
この件に関して、他の方の意見を聞かせていただけると助かります。  
また、自分で実装を書いてみたのですが『とりあえず動いている』というレベルなので、Refinements の実装に詳しい方がいればパッチもみていただけると助かります。  


---Files--------------------------------
refinemetns_to_proc.patch (3.73 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50405] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
       [not found] <redmine.issue-14223.20171222164605@ruby-lang.org>
  2017-12-22 16:46 ` [ruby-dev:50384] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案 manga.osyo
  2017-12-26  8:39 ` [ruby-dev:50395] " nobu
@ 2017-12-29  6:47 ` manga.osyo
  2018-01-24  6:01 ` [ruby-dev:50422] " matz
  2018-01-26  2:22 ` [ruby-dev:50434] " manga.osyo
  4 siblings, 0 replies; 5+ messages in thread
From: manga.osyo @ 2017-12-29  6:47 UTC (permalink / raw)
  To: ruby-dev

Issue #14223 has been updated by osyo (manga osyo).

File refinemetns_to_proc.patch added

nobu (Nobuyoshi Nakada) wrote:
> 賛成です。

返信して頂き、ありがとうございます。

> できれば不要なインデントの変更などは混ぜないでください。

ありがとうございます。修正しました。
これで問題ないでしょうか。

----------------------------------------
Feature #14223: Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
https://bugs.ruby-lang.org/issues/14223#change-69089

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Refinements に関する提案です。  
現行の仕様では Refinements で定義された `#to_proc` は `&hoge` 時に暗黙的に呼びだされません。  

```ruby
using Module.new {
	refine String do
		def to_proc
			proc { |it| it.send self }
		end

		def refine_method
			"X#refine_method"
		end
	end
}

def func &block
end

p "upcase".refine_method
# => "X#refine_method"

p "upcase".to_proc.call "homu"
# => "HOMU"

# Error: wrong argument type X (expected Proc) (TypeError)
func &"upcase"
```

実行結果:https://wandbox.org/permlink/j8Hhavy7LoKYjrnz


最近の傾向として `Kernel#send` や式展開時の `#to_s` などで Refinements が有効になっています。
そういう意味では `&hoge` で暗黙的に呼び出される `#to_proc` も Refinements が有効になってもよいのではないでしょうか。  
この件に関して、他の方の意見を聞かせていただけると助かります。  
また、自分で実装を書いてみたのですが『とりあえず動いている』というレベルなので、Refinements の実装に詳しい方がいればパッチもみていただけると助かります。  


---Files--------------------------------
refinemetns_to_proc.patch (3.73 KB)
refinemetns_to_proc.patch (3.26 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50422] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
       [not found] <redmine.issue-14223.20171222164605@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-12-29  6:47 ` [ruby-dev:50405] " manga.osyo
@ 2018-01-24  6:01 ` matz
  2018-01-26  2:22 ` [ruby-dev:50434] " manga.osyo
  4 siblings, 0 replies; 5+ messages in thread
From: matz @ 2018-01-24  6:01 UTC (permalink / raw)
  To: ruby-dev

Issue #14223 has been updated by matz (Yukihiro Matsumoto).


良さそうに思えます。取り込んでみましょう。

Matz.


----------------------------------------
Feature #14223: Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
https://bugs.ruby-lang.org/issues/14223#change-69734

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Refinements に関する提案です。  
現行の仕様では Refinements で定義された `#to_proc` は `&hoge` 時に暗黙的に呼びだされません。  

```ruby
using Module.new {
	refine String do
		def to_proc
			proc { |it| it.send self }
		end

		def refine_method
			"X#refine_method"
		end
	end
}

def func &block
end

p "upcase".refine_method
# => "X#refine_method"

p "upcase".to_proc.call "homu"
# => "HOMU"

# Error: wrong argument type X (expected Proc) (TypeError)
func &"upcase"
```

実行結果:https://wandbox.org/permlink/j8Hhavy7LoKYjrnz


最近の傾向として `Kernel#send` や式展開時の `#to_s` などで Refinements が有効になっています。
そういう意味では `&hoge` で暗黙的に呼び出される `#to_proc` も Refinements が有効になってもよいのではないでしょうか。  
この件に関して、他の方の意見を聞かせていただけると助かります。  
また、自分で実装を書いてみたのですが『とりあえず動いている』というレベルなので、Refinements の実装に詳しい方がいればパッチもみていただけると助かります。  


---Files--------------------------------
refinemetns_to_proc.patch (3.73 KB)
refinemetns_to_proc.patch (3.26 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50434] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
       [not found] <redmine.issue-14223.20171222164605@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2018-01-24  6:01 ` [ruby-dev:50422] " matz
@ 2018-01-26  2:22 ` manga.osyo
  4 siblings, 0 replies; 5+ messages in thread
From: manga.osyo @ 2018-01-26  2:22 UTC (permalink / raw)
  To: ruby-dev

Issue #14223 has been updated by osyo (manga osyo).


ありがとうございます!

----------------------------------------
Feature #14223: Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案
https://bugs.ruby-lang.org/issues/14223#change-69849

* Author: osyo (manga osyo)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Refinements に関する提案です。  
現行の仕様では Refinements で定義された `#to_proc` は `&hoge` 時に暗黙的に呼びだされません。  

```ruby
using Module.new {
	refine String do
		def to_proc
			proc { |it| it.send self }
		end

		def refine_method
			"X#refine_method"
		end
	end
}

def func &block
end

p "upcase".refine_method
# => "X#refine_method"

p "upcase".to_proc.call "homu"
# => "HOMU"

# Error: wrong argument type X (expected Proc) (TypeError)
func &"upcase"
```

実行結果:https://wandbox.org/permlink/j8Hhavy7LoKYjrnz


最近の傾向として `Kernel#send` や式展開時の `#to_s` などで Refinements が有効になっています。
そういう意味では `&hoge` で暗黙的に呼び出される `#to_proc` も Refinements が有効になってもよいのではないでしょうか。  
この件に関して、他の方の意見を聞かせていただけると助かります。  
また、自分で実装を書いてみたのですが『とりあえず動いている』というレベルなので、Refinements の実装に詳しい方がいればパッチもみていただけると助かります。  


---Files--------------------------------
refinemetns_to_proc.patch (3.73 KB)
refinemetns_to_proc.patch (3.26 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-26  2:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-14223.20171222164605@ruby-lang.org>
2017-12-22 16:46 ` [ruby-dev:50384] [Ruby trunk Feature#14223] Refinements で定義した #to_proc が &hoge 時に呼ばれないのを緩和する提案 manga.osyo
2017-12-26  8:39 ` [ruby-dev:50395] " nobu
2017-12-29  6:47 ` [ruby-dev:50405] " manga.osyo
2018-01-24  6:01 ` [ruby-dev:50422] " matz
2018-01-26  2:22 ` [ruby-dev:50434] " manga.osyo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).