Closed SignpostMarv closed 5 years ago
Can you do this in another language that supports templated types (e.g. TypeScript, HackLang etc.)? If you can, I'm might add it, if you can't I won't.
The closest thing I'm seeing on TypeScript is function getProperty<T, K extends keyof T>(obj: T, key: K) { return obj[key]; }
which doesn't quite seem to be the point ?
c# has T.GetGenericArguments() and there's a java thing both of which are runtime not docblocks or syntax :s
c# has T.GetGenericArguments()
p.s. this would suggest @template T2 as generic-arguments(T1, 0)
?
yeah, but those are all runtime things - closing, but feel free to implement if you feel strongly
Where might one have to start digging around to implement this ?
Whilst one could implement a factory on an object to return correctly-templated instances of a given class (i.e. with a model that has a method to return an instance of a class designed to track changes to the model), there are patterns where this is cludgy (i.e. in repository pattern, objects/models should not have knowledge of repositories).
I'm wondering if there's sufficient utility for a template param "function" to declare a given template param is identical to the named template param from one of the supplied template params (i.e. requiring the specified template param to refer to a class), e.g.: