From: "David A. Black" Date: 2004-12-01T20:16:56+09:00 Subject: Re: Optional static typing (or, What can Ruby 2.0 borrow from Boo?) Hi -- On Wed, 1 Dec 2004, Lothar Scholz wrote: > Hello gabriele, > > gr> Lothar Scholz ha scritto: > > > gr> Anyway, notice that I submitted RCR280 wich actually allow you to give > gr> type assertions if you want them: > > I must say that i don't like it because it mixes again runtime and > compile time. i would really favour: > > # if you want to add an integer to a subclass of Numeric > def sum a,b > assert_type "a => Numeric, b = Integer" > a+b > end > > Only if everything can be extracted statically (by looking at the code) > then you get into a better position then what is currently available. > > Mixing another special feature like conversion into this is something > i absolutely don't like. Two different purposes should have to > different notations. Also your RCR makes the situation worse, adding > more invisble magic. But the main goal here is to be more verbose. > > The assert_type could be extended to help with collections and other > things a little bit: > > assert_type "h => Hash[Integer], object.foo = String, @myvar = Dummy" If you're going to write this, or propose it as an RCR, it would be better to call it "assert_class", or "assert_isa", to keep clear the important distinction between type and class in Ruby and the fact that this is a class-name/hierarchy check, rather than a type check. David -- David A. Black dblack@wobblini.net