Re:What can we learn from how compilers are designed?
by jonathanyc on Friday March 16, 2018 @08:03PM
(#16604868)
I wish there were tools to auto generate documentation on what interface a duck-typed consumer expects, e.g. what std::vector<T> expects of T.
[ Parent
| on HN ]
Re:What can we learn from how compilers are designed?
by stochastic_monk on Friday March 16, 2018 @08:12PM
(#16604905)
Well, C++17 concepts enforce requirements, but hopefully metaclasses will do more in 20.
Re:What can we learn from how compilers are designed?
by bstamour on Saturday March 17, 2018 @08:22AM
(#16606647)
Concepts are also C++20. They were voted in, however, shortly after 17 shipped.
Re:What can we learn from how compilers are designed?
by stochastic_monk on Saturday March 17, 2018 @11:17AM
(#16607316)
Good point. I was thinking of the rudimentary, template-based use of concepts, not the polished, C++20 version.
Re:What can we learn from how compilers are designed?
by bstamour on Saturday March 17, 2018 @02:18PM
(#16608253)
Ah gotcha. Yes in the current situation we can do nearly everything that the concepts proposal for C++20 does with enable_if, void_t, and a few other helpers. Though concepts have the benefit of letting you "say what you mean", instead of relying on template magic.
Re:What can we learn from how compilers are designed?
by orf on Friday March 16, 2018 @09:07PM
(#16605072)
This should be more than possible with Pythons type annotations, when done right. I.e 'iterable[str]' can accept a generator, list, tuple, any class with the right __iter__ and of course a string itself.
Re:What can we learn from how compilers are designed?
by wirrbel on Saturday March 17, 2018 @03:26PM
(#16608582)
This is what I like about Rust and Rust's traits. You write a generic and specify the properties of the generic type parameter, for example that it must implement another trait or something.