3 ms·
C++ and Scala don't really have dependent typing, but rather a single feature that is typical of dependent typing. That is: type-level values of any type.
by Peaker 9y ago
C++ and Scala don't really have dependent typing, but rather a single feature that is typical of dependent typing. That is: type-level values of any type.
- taejo 9y agoDoesn't C++ only have type-level integers (as template parameters)? Are you referring to something else?
- Peaker 9y agoI haven't used C++ in years. That may be true. In that case, it may be even more puzzling to claim that C++ has dependent types.
- johncolanduoni 9y agoBoth Scala and C++ have a set of type-system features that when combined allow you create functions whose return type can depend on the value of the passed argument. For a good step by step of how to do this in Scala see here[1], and a (unfortunately less in depth) C++ example is here[2]. [1]: http://gigiigig.github.io/tlp-step-by-step/dependent-types.html http://gigiigig.github.io/tlp-step-by-step/dependent-types.h... [2]: https://www.reddit.com/r/cpp/comments/2tilfw/dependent_typing_in_c/ https://www.reddit.com/r/cpp/comments/2tilfw/dependent_typin...
- Peaker 9y agoI am not familiar enough with Scala, but the C++ example certainly does not seem like dependent types. Which function in there do you consider to have a return type that depends on the value of the input?