4 ms·
Both 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 argu
by johncolanduoni 9y ago
Both 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?