From: matz@... (Yukihiro Matsumoto) Date: 2003-11-21T06:13:15+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) Hi, In message "Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types)" on 03/11/20, "T. Onoma" writes: |the type system that you are seeking, suitable to the dynanicism of ruby, can only really come from the proper type of reflection. for ruby that is duck type reflection. -- being able of "ask" a method what it would do with the objects passed to it, the result is a method's duck type signature. | | def whatiwould(x, y=0) | x.to_i | y.succ | y + 1 | end | | method(:whatiwould).duck_signature # -> [ [ 'to_i' ], [ 'succ', '+' ] ] | |this tells you what methods the parameters must respond_to. Interesting. To tell the truth, I thought it as an typing in Ruby before. But I'm afraid this feature requires definite flow analysis, which is nearly impossible in the language like Ruby. def whatiwould(x, flags) if flags x = Regex.new(x.join("|")) end x.match(@str) end method(:whatiwould).duck_signature # -> [['join','match'], []] # no! That's one of the reason there is no non-functional type inference language. matz.