You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unlike C++ templates generics in .NET directly exist in IL. How we could handle this is to substitute the type parameters (also a bit like with C++ templates) and basically create a version of the generic class for each type it's used with.
This can happen similarly to how array types are created in VHDL, e.g. we'd create a class named Generic_int and Generic_long from two usages of Generic<T>.
Possibly the best way to implement this would be via an AST processor in the Transformer.
Ideally, there would be a way to get rid of generics in IL and somehow substitute them statically (by the compiler or with some IL tool) but there seems to be no way to do this.
Having arrays of struct-s + a generic SimpleMemory<T> (of structs) would be very handy for image processsing applications. I guess you need to follow some alignment rules on the hardware, so there might be contstraints, but couldn't it be viewed as sugar around byte[] for well-aligned data?
That's a good idea with SimpleMemory, and indeed it would be a nice addition. Since this is implementation-wise a different issue from user-defined generic types, let's follow it up here: #25.
BTW you can already define arrays of any supported type, including custom structs (but not store them directly in SimpleMemory).
Support for generic types, i.e.
Generic<T>
.Unlike C++ templates generics in .NET directly exist in IL. How we could handle this is to substitute the type parameters (also a bit like with C++ templates) and basically create a version of the generic class for each type it's used with.
This can happen similarly to how array types are created in VHDL, e.g. we'd create a class named
Generic_int
andGeneric_long
from two usages ofGeneric<T>
.Possibly the best way to implement this would be via an AST processor in the Transformer.
Ideally, there would be a way to get rid of generics in IL and somehow substitute them statically (by the compiler or with some IL tool) but there seems to be no way to do this.
Jira issue
The text was updated successfully, but these errors were encountered: