Generics and templating: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 55: | Line 55: | ||
you might be able to do generics only by forgetting type information in the process - which you might call '''type erased generics'''. | you might be able to do generics only by forgetting type information in the process - which you might call '''type erased generics'''. | ||
For example, Java has allowed a ''kind'' of generics for a long time, in that you can see every object as Object | For example, Java has allowed a ''kind'' of generics for a long time, in that you can see every object as an Object before handing it around, and hoping you only hand it to something that doesn't confuse what more specific type it actually is, or for you to hand that information along some indirect way. | ||
This type-erasing generics seems to have been done at the time to have backwards compatibility - older runtimes would still understand this newer style of generic classes, because they weren't really special{{verify}}. | This type-erasing generics seems to have been done at the time to have backwards compatibility - older runtimes would still understand this newer style of generic classes, because they weren't really special{{verify}}. | ||
In such contexts, '''reified generics''' refer to the situation where the compiler | In such contexts, '''reified generics''' refer to the situation where the compiler / editor / runtime knows and preserves the type, for syntax to use. | ||