From: Hal Fulton Date: 2005-05-04T08:24:15+09:00 Subject: Re: Typo-checking instead of static typing Nick Woolley wrote: > > Also, conceivably, couldn't (optional) implicit run-time checks be added > which match the declared 'type' of an assignee variable to the current > type of the assigned object? No type inference, just a little extra > runtime overhead (which could be switched off). And/or similar optional > preconditions on method arguments? > > e.g. > > Fruit var1 = Banana.new # ok > Flesh var2 = Sausage.new # ok > Object var3 = Hamster.new # no checks on this var > var3 = var2 # so, Sausages are okay here > var3 = var1 # so are Bananas > var1 = var2 # but not here, cos Sausages aren't Fruit - bang! > var4 = 0 # var4 isn't predeclared - bang! > > Um, this seems so obvious I am expecting someone to reveal my > cluelessness imminently. > It's not a question of cluelessness, but I would state it this way: Absence of explicit typing and variable declarations are two of Ruby's best features, and they are foundational in its design. Hal