Ask HN: What languages include implicit condition checking?
Not even sure if I'm using the right name. I've been doing a lot of precondition / type checking in PHP, and it occurred to me that it might be a cool language feature to bake into a language. For example, perhaps I could write `$i = count($keys) = count($values)` if I want $i to be set only on the conditions that $keys and $values are equi-lengthed array. An more advanced implementation could include auto checking a function's inputs, based on some set of rules defined in syntax or comments.
4 comments
[ 3.2 ms ] story [ 17.6 ms ] threadhttp://www.php.net/manual/en/language.oop5.overloading.php#o...
The original one is Eiffel, if I'm not mistaken: http://en.wikipedia.org/wiki/Precondition#Eiffel_example
Clojure: http://blog.fogus.me/2009/12/21/clojures-pre-and-post/
Ada 2012, apparently: http://www.adacore.com/uploads/technical-papers/Ada2012_Rati...
The slightly lesser known Cobra: http://cobra-language.com/trac/cobra/wiki/Contracts
(of these, I only ever wrote Clojure, and I've used a couple preconditions in production, I definitely like the concept)