It has reified generics ... how is that implemented? Any significant difference from C#'s generics?
-
Also I suggest should retag this as "gosu-lang" or something to that effect. The existing gosu tag was being used for the graphics library of the same name. – Mike Miller Nov 10 '10 at 19:24
-
@Mike - done. Also asked on meta - http://meta.stackexchange.com/questions/69940/what-should-be-done-with-the-gosu-tag – ripper234 Nov 10 '10 at 22:01
-
Cool, thanks. I should have looked there first, as usual. :) – Mike Miller Nov 11 '10 at 15:16
-
@Mike - actually, I asked it there _after_ your comment! – ripper234 Nov 11 '10 at 17:48
2 Answers
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.

- 24,795
- 10
- 66
- 61
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:

- 1
- 1

- 2,149
- 1
- 18
- 23