3 ms·
I have a system set up in C++ to make it trivial to add new unique kinds of IDs (wrappers around ints) as well as vectors that can be indexed only with that kin
by dfan 8y ago
I have a system set up in C++ to make it trivial to add new unique kinds of IDs (wrappers around ints) as well as vectors that can be indexed only with that kind of ID. So you can have a ShoeVec containing Shoes that is indexable only by ShoeIDs and a ShirtVec containing Shirts that is indexable only by ShirtIDs. It's zero-overhead in optimized builds, of course. You'd be surprised how rarely you have to convert to or from the underlying type.
- jdonaldson 8y agoFwiw the Haxe language calls this an "abstract type", and they're very useful. https://haxe.org/manual/types-abstract.html https://haxe.org/manual/types-abstract.html
- deleted 8y ago[deleted]
- rurban 8y agoGeneric types are useful, but still should be called as such, or for the new fad: dependent types. Abstract types would not allow instantiation.
- jdonaldson 8y agoHaxe abstract types are distinct from abstract classes, but I need to learn more about dependent types.
- kazinator 8y agoCongrats, you almost have Pascal there.