From: Chris Uzdavinis Date: 2001-08-12T23:50:23+09:00 Subject: [ruby-talk:19606] Re: order and freedom in Ruby (was: Re: Re: the way class variables work) > "The use of pre and post conditions allows the development of > software to be thought of as an implicit, or explicit, contract > between the calling environment and the called subprogram. The > calling environment fulfils its part of the contract by ensuring > that it only ever calls the subprogram with a set of actual > parameters which comply with the pre-condition. The subprogram in > its turn fulfils the contract by ensuring that if it is supplied > with acceptable input parameters it will always provide results > which comply with its post-condition. That is to say that it will > fulfil its advertised specification to transform its input data into > the output data." Yes, that's what I'm talking about. (Thanks for the link.) However, that's where I'm troubled. This definition indicates that passing in valid arguments is all that is necessary to guarnatee that the contract is satisified. But that's not necessarily sufficient in ruby, because the implementation of the function relies on basic fundamental constructs of the language (array indexing, hash lookup, string compare, etc) but someone can redefine that behavior in a non-compatible way. If I write a sort routine, and you give me a comparison function (proc object perhap) to use to create my ordering, and you give me completely valid arguments, completely correct proc object, etc, I still cannot guarantee that my function will result in your data being sorted. External code changes can break the sort routine without touching its code. -- Chris