Shinji KOBAYASHI wrote:

> Iterator<DvText> it = someRmArrayInstance.iterator()
> 
> But I found it must be cut off by 'Occam's razor' in Ruby.
> 
> it = some_rm_array.iterator
> 
> This code looks curious for Java/Eiffel/C# user who are similar to generics,
> but it is enough for encapsulated object instance.

Ruby is a dynamic language, so I guess it would have no need for generics. If 
you provide a wrongly typed object to a collection in Ruby, I imagine (never 
having programmed in Ruby myself) that you would find out about the error when 
you run the program.

Eiffel, C# and Java try to catch errors like that during compilation. Generics 
is useful for those languages: it tries to keep the extra safety of 
compile-type checking, while providing some of the flexibility that you get in 
dynamic languages like Ruby.

In the case of Java, generics don't work very well, as Seref pointed out. The 
JVM forced the Java designers to adopt a policy of "type erasure". And so, on 
the one hand, the compiler is less flexible than Eiffel and C#, rejecting a lot 
of uses of generics that would be permitted in those other languages; and on 
the other hand, the Java byte code that you finish up running in the JVM 
contains no info about the generic parameter type.

I'm not clear why the existence of generics in the spec would be a problem for 
a dynamic language like Ruby.

Peter


Reply via email to