Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The standard bearer for contracts used to be Eiffel, which people stopped caring about in the mid-90’s. Nowadays the only mainstream language to get serious about contracts is Clojure. Most languages have a contracts library, which mean the language doesn’t have affordances to use contracts well. Take the predicate is_sorted(l)

Some languages though have contracts as a library, but that library uses tools of the language, to actually change the language. Languages with capable macro systems! Just because something is a library, that does not mean, that it will not integrate into the language, even beyond a library function level. In language with a capable macro system, one can create new keywords and forms, which are just as much part of the language, as predefined things. It allows to create ones "affordances". With all the interest in language features, I am surprised, that this was overlooked.

The post inspired me to try myself at creating a macro in Scheme / GNU Guile, which implements the "requires" and "ensures" idea, although evaluating at runtime: https://notabug.org/ZelphirKaltstahl/guile-examples/src/d749...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: