From: matz@... (Yukihiro Matsumoto) Date: 2003-11-22T08:37:03+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) ) Hi, In message "Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) )" on 03/11/22, "Weirich, James" writes: |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 I'd be second to Chad. Cool. |An aside: Unfortunately, the post method doesn't have access to the result |returned from the function. In this case it doesn't matter, but many post |conditions assert something interesting about the result. I guess I would |have to use a wrap method for that. The only reason the result is _not_ available from post method is we don't have neat syntax construct. Any proposal? matz.