[EMAIL PROTECTED] (Alex Martelli) writes: > I've always liked the (theoretical) idea that assertions (including of > course contracts) could be used as axioms used to optimize generated > code, rather than (necessarily) as a runtime burden. E.g. (and I don't > know of any implementation of this concept, mind you), inferring (e.g. > from such assertions) that x>=0, and that y<0, the compiler could simply > cut away a branch of dead code guarded by "if x<y:" (maybe with a > warning, in this case;-)...
A few months ago, a troll challenged the denizens of comp.lang.lisp to write a Lisp implementation of some some code which he posted in C++, which would be competitive in terms of speed with his C++ version. The c.l.lers duly obliged, and, IIRC, it so happened that the improvement that made the Lisp version overtake the C++ one was the declaration of some variable to be of type "floating point number in the range 0 to two Pi". Of course, in CL type declarations are not contracts, but promises to the compiler ... but it's still an examlpe of a situation where more specific type information allowed the compiler to produce more efficient code, in practice. -- http://mail.python.org/mailman/listinfo/python-list