On Sat, 22 Nov 2003, Weirich, James wrote:

# I've been thinking about DbC stuff for some time and something in Matz Ruby
# 2 talk last Saturday sparked an idea along these lines ...
# 
#    class Person
#      def greet(other_person)
#        marry(other_person)
#      end
#    end
# 
# Then specify the contract in a separate file ...
# 
#    class Person
#      def greet:pre(other_person)
#        assert ! self.married?
#        assert ! other_person.married?
#      end
# 
#      def greet:post(other_person)
#        assert other_person.married?
#        assert self.married?
#        assert_equal self, other_person.spouse
#        assert_equal other_person, self.spouse
#      end
#    end
# 


Very cool, Jim.  It makes me wonder what other "paradigms" might be 
available without language modifications.  There are, of course, some 
limitations to this as you point out, but this simple wrapping adds a lot 
of flexibility.

A question for Matz (and Sean, for that matter):  I've heard Sean say that 
you could turn off his stuff in production (maybe it was the old 
proprosal...can't remember).  How would you feel in general about 
implementing a system that actually slows things down, but with the idea 
that you wouldn't use it in production?

We don't stress out too much about making debuggers that will allow our 
code to run at full speed.  And, from what I've heard from the proponents 
of interface checking, the desire is to help *people*--not computers.  

So, why worry too much about speed?  You could potentially implement 
something using pre/wrap/post (or some sugary-syntax derivative), and so 
what if it has to use respond_to? and slow things down?  You just remove 
it before you actually put the code into use.


Thoughts?