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

linjunpop · 2012年11月30日 · 最后由 James_Zhan 回复于 2012年12月10日 · 2449 次阅读

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 的问题。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号