r/ProgrammingLanguages • u/levodelellis • Feb 08 '26
Languages with strong pre/post conditions?
I had some random thoughts. I have class where if I call setThing(N); another function (process) will return an array with at minimum (or exactly) N elements. Is that expressible in any languages?
I always though D pre/post/invariant was interesting. I know ada and spark has more (I plan to look at spark). Is there any languages that can express process returning Array [n] where n is the parameter of setThing? What languages should I look at if I'm interested in contract programming?
I'll likely keep a list of ideas and try to figure it out when I want to implement another programming language
View all comments
Show parent comment
1
u/ejstembler kit-lang.org Feb 28 '26
I think so.
The main idea from Design-by-Contract, pre-conditions and post-conditions, can be utilized in most languages. I've used them in Ruby, Python, Clojure, and in statically type lanugages too, Java, C#, etc.
Python snippet:
Ruby snippet:
Refinement types I've only seen in functional languages.
In my new language I support contracts and refinements.