Talk:Assertions in design by contract

From Rosetta Code

Asserts in C are supposed to check at runtime during development, as an aide to the programmer, but not be compiled into a release version. This behavior is often imitated by putting a test in while code is being developed and then commenting it for release. So assert may be seen as a sort of comment in this case.

You also mention assert as a part of DbyC. According to wiki the following languages support DbyC as core:

    1. Ada 2012
    2. Ciao
    3. Clojure
    4. Perl6
    5. Cobra
    6. D[8]
    7. Eiffel
    8. Fortress
    9. Lisaac
    10. Mercury
    11. Nice
    12. Oxygene (formerly Chrome)
    13. Racket (including higher order contracts, and emphasizing that contract violations must blame the guilty party and must do so with an accurate explanation[9])
    14. RPS-Obix
    15. Sather
    16. SPARK (via static analysis of Ada programs)
    17. Spec#
    18. Vala
    19. VDM

and the following using external packages:

    1. Ada, via GNAT pragmas for preconditions and postconditions.
    2. C and C++, via the DBC for C preprocessor, GNU Nana, eCv static analysis tool, or the Digital Mars C++ compiler, via CTESK extension of C. Loki Library provides a mechanism named ContractChecker that verifies a class follows design by contract.
    3. C# (and other .NET languages), via Code Contracts (a Microsoft Research project integrated into the .NET Framework 4.0)
    4. DELPHI PRISM, see [1]
    5. Groovy via GContracts GContracts
    6. Java, via Contracts for Java, iContract2/JContracts, Contract4J, jContractor, C4J, Google CodePro Analytix, Jass preprocessor, OVal with AspectJ, Java Modeling Language (JML), Jtest, SpringContracts for the Spring framework, Modern Jass, JavaDbC using AspectJ, JavaTESK using extension of Java, chex4j using javassist, and the highly customizable java-on-contracts.
    7. JavaScript, via Cerny.js, ecmaDebug, jsContract, or jscategory.
    8. Common Lisp, via the macro facility or the CLOS metaobject protocol.
    9. Nemerle, via macros.
    10. Perl, via the CPAN modules Class::Contract (by Damian Conway) or Carp::Datum (by Raphael Manfredi).
    11. PHP, via PhpDeal, Praspel or Stuart Herbert's ContractLib.
    12. Python, using packages like zope.interface, PyDBC or Contracts for Python.
    13. Ruby, via Brian McCallister's DesignByContract, Ruby DBC ruby-contract or contracts.ruby.
    14. Tcl, via the XOTcl object-oriented extension

I have added an example of Ruby using [contracts.ruby]. Can we clarify which approach is required here. A solution which just puts an if statement in a procedure named assert does not achieve either.--Nigel Galloway (talk) 12:20, 1 October 2014 (UTC)

I hope we are going for DbyC. I shall look forward to the Racket solution "emphasizing that contract violations must blame the guilty party and must do so with an accurate explanation". Programmers will be taken out and shot!!!!--Nigel Galloway (talk) 12:29, 1 October 2014 (UTC)