3

It has reified generics ... how is that implemented? Any significant difference from C#'s generics?

skaffman
  • 398,947
  • 96
  • 818
  • 769
ripper234
  • 222,824
  • 274
  • 634
  • 905

2 Answers2

2

Difference from C# generics: for different instantiations of a generic class, C# generates classes at runtime. Gosu does not: one generic class corresponds to one class used at runtime. The type information is retained inside objects, not in classes. Thus, C# can specialize the code (e.g. for primitive types), while Gosu can not. For example, Gosu must wrap ints into objects to put them into a list.

Andrey Breslav
  • 24,795
  • 10
  • 66
  • 61
1

Having only recent looked at Gosu, and not actually wrote any real programs in it yet; the best I can tell is that reified generics refers to the fact that Gosu is retaining the original type of the genricized object.

In Java there is no way without resorting to reflection to find out what the original type of something passed into a generic function is.

Look at the bottom of this page in the documentation. It does not say actually how to do it, but just that it can.

Also take a look at these questions:

Community
  • 1
  • 1
Mike Miller
  • 2,149
  • 1
  • 18
  • 23