分享 Matz: I decided not to introduce full refinement for Ruby 2.0

linjunpop · November 30, 2012 · Last by James_Zhan replied at December 10, 2012 · 2451 hits

https://bugs.ruby-lang.org/issues/4085#note-175

Since there still remain undefined corner case behavior in refinements, and the time is running out, I decided not to introduce full refinement for Ruby 2.0. The limited Ruby 2.0 refinement spec will be:

  • refinements are file scope
  • only top-level "using" is available
  • no module scope refinement
  • no refinement inheritance
  • module_eval do not introduce refinement (even for string args)

很多特性用不到的,呵呵。

File scope 应该还算比较靠谱,和.NET 有点类似,可以作为 Open Class 的有效补充。不过确实有点鸡肋。增加程序员的负担,但是可以有效避免 Monkey Patch 的问题。

You need to Sign in before reply, if you don't have an account, please Sign up first.