Contracts for C

41 joexbayer 6 9/5/2025, 6:36:49 AM gustedt.wordpress.com ↗

Comments (6)

WalterBright · 1h ago
Digital Mars C++ has had contracts since, oh, the early 1990s?

https://www.digitalmars.com/ctg/contract.html

taminka · 37m ago
do i understand correctly that there's nothing preventing someone from adding a postcondition check X and then just not implementing it inside the function? wouldn't this just mean that now the ub is triggered by the post()'s `unceachable()` instead of whatever ub would happen w/, say, dereferencing a null pointer, as a consequence of not actually implementing post check X? so it's just for speed optimisations then?

from reading about contracts for C before i assumed it would be like what cake[1] does, which actually compile time enforces pointer (non)nullability, as well as resource ownership and a bunch of other stuff, very cool project, check it out if you haven't seen it yet :)

[1]https://github.com/thradams/cake

__d · 2h ago
I like Eiffel.

But if I want to use Eiffel, I’ll use Eiffel (or Sather).

I’d rather C remained C.

Maybe that’s just me?

jimbob45 · 46m ago
Java 24 and C# 9 resemble little of their first versions. C++ might as well not even be the same language at this point. Why are we so conservative with C but then so happily liberal with every other language?
HexDecOctBin · 6m ago
People chose C because they liked C. Of course they don't want C to change. The only thing the ISO committee should be doing is filling in the holes in language (C23's Improved Tag Compatibility and __VA_OPT__ are good examples), not add features that were never part of C and were never supposed to be there.

Your question can be reflected back to you: if you want an ever changing languages, go to Java, C# or C++, why mess with C?

dmitrygr · 7m ago
Because there must be at least one refuge for the sane