Generics and templating: Difference between revisions

From Helpful
Jump to navigation Jump to search
mNo edit summary
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 type before handing it around{{verify}}, 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.
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{{verify}} knows and preserves the type, for syntax to use.  
In such contexts, '''reified generics''' refer to the situation where the compiler{{verify}} knows and preserves the type, for syntax to use.





Revision as of 13:57, 9 January 2024