3 ms·
Ada (https://learn.adacore.com/courses/intro-to-ada/chapters/contracts.html https://learn.adacore.com/courses/intro-to-ada/chapters/cont...) and Eiffel (https:/
by thesuperbigfrog 7y ago
Ada (https://learn.adacore.com/courses/intro-to-ada/chapters/contracts.html https://learn.adacore.com/courses/intro-to-ada/chapters/cont...) and Eiffel (https://www.eiffel.com/values/design-by-contract/introduction/ https://www.eiffel.com/values/design-by-contract/introductio...) also support contracts.
Contract-based programming is a very nice way to quickly find errors and specify how different parts of the program should interact.
- pjmlp 7y agoC++20 almost got them. There are some Java annotation processors that rewrite the bytecode for contracts. As extra info.
- thesuperbigfrog 7y agoJava annotations have always struck me as interesting since they fill the Lisp macros and C preprocessor niche for Java. It's another layer of complexity, but it extends the language to offer a bit more richness or layers of abstraction. I would not be surprised if a future C++ standard adds contracts officially. Boost seems to already have contracts: https://www.boost.org/doc/libs/1_67_0/libs/contract/doc/html/boost_contract/contract_programming_overview.html https://www.boost.org/doc/libs/1_67_0/libs/contract/doc/html...
- pjmlp 7y agoYes, many aren't aware how much annotation processors and compiler plugins are capable of. On the .NET side you have Roslyn, Attributes, expression trees and on F# quotations. While they are all a bit cumbersome to use versus what Lisp macros allow for, they already allow for quite a lot. Yes, there is some hope that C++23 will bring them. The more languages support DbC the better, only so can we start seeing more widespread adoption across the industry.