From: Yusuke ENDOH Date: 2010-11-26T12:45:24+09:00 Subject: [ruby-core:33402] Re: [Ruby 1.9-Feature#4085][Open] Refinements and nested methods Hi, 2010/11/26 Shugo Maeda : >>> I guess Module#refine works the same as using_refine in this case. >> >> Hmm. �Then, when no block is given to Module#refine, how about >> adding an implicit block that includes the outer module? >> >> �module FooExt >> � �refine(Foo) >> � �... >> �end >> >> (equivalent to) >> >> �module FooExt >> � �refine(Foo) { include FooExt } >> � �... >> �end > > Could you tell me why you need this feature? Because it requires less indentation, I thought. But I found out that it has a problem of [ruby-core:33386] (1)... >>> I don't think we need new keywords even if it is a big change, >>> because some essential features such as module inclusion >>> have no keyword in Ruby. >> >> Indeed. �But conventionally, essential features that involve >> code block (such as class/module definition, method definition >> and control statements) have their special keywords. > > I guess that most of these constructs have reasons why they need > keywords and special syntax. I don't think so. "class Foo; end" can be written as "Foo = Class.new { }" (though there are indeed subtle differences between them). > If refine is a keyword, there is one good thing. �We don't need "do" > after class names. > > �refine Fixnum > � �... > �end The API design that "def" statements are put in a Ruby's block, is slightly weird (for me). I guess that there is no precedent of such a style in Ruby's embedded featues, except meta programming (such as Class.new and class_eval). From now on, does Ruby encourage such a style in casual use? -- Yusuke Endoh