3 ms·
They're subsets of true dependent types, in my understanding. This is because they can only do this at compile time, not runtime. There's no way to say, get a n
by steveklabnik 5y ago
They're subsets of true dependent types, in my understanding. This is because they can only do this at compile time, not runtime. There's no way to say, get a number over stdin, put it in a variable n, and then instantiate MyType<n> with that variable. You can with true dependent types.
- stkdump 5y agoYou could do this with the factory pattern, applied to a template type. Though, if you would do this for the whole range of say, an int, you would probably blow up the compiler. How is that done in languages that do support this? Or does it require shipping the compiler, so that you can run the compiler at runtime?
- steveklabnik 5y ago> You could do this with the factory pattern, applied to a template type. I don't know enough about C++ templates here, but you cannot in Rust. > How is that done in languages that do support this? I don't know enough about the implementations to actually say, to be honest. Most of them aren't systems languages, and so have significantly less constraints on implementations, and less monomorphization. I imagine that helps.