Given the discussion in the past on Eiffel-like features for Ruby, I pass this on in the hope that it may stimulate something useful. My memory of the discussion, which could be wrong, was that to provide these features for a dynamic language such as Ruby was particularly difficult. When I saw this response to my saying this, I asked if I could post this to the list/group. Richard agreed. Hugh ---------- Forwarded message ---------- Date: Tue, 10 Jul 2001 12:30:19 +1200 (NZST) From: Richard A. O'Keefe <ok / atlas.otago.ac.nz> To: hgs / dmu.ac.uk Subject: Re: Software testing for Icon? > The reason Eiffel is a bit better off here is that you can state the > - class invariant for a class > - preconditions for a method > - postconditions for a method > and a descendant class may only > - strengthen the class invariant > - weaken the preconditions for a method > - strengthen the postconditions for a method > so when a descendant's construction code must leave the object in a state > that the ancestor is happy with and a descendant's method must "satisfy > the contract" of the ancestor's version; it can't do something completely > different. Yes, these are good points. There has been talk about putting these things into Ruby, but it seems to be deifficult for languages that are dynamic. Eh? Common Lisp has (check-type Generalised-Variable Type-Specifier [String]) (assert Boolean-Expression [(Generalised-Variable...)] [String ...]) Admittedly the existing method combinations in the Common Lisp Object System don't have provision for pre- and post- conditions, but in those Lisp implementations that support the Meta-Object Protocol it is entirely possible to program it. And Common Lisp is as dynamic as they come. The implementation machinery used for the (trace Function...) macro should be usable for attaching checking code to functions, including generic functions; the Interlisp version of this, called the Advice Package, was certainly so used (by me amongst others). Indeed, I adapted the Advice Package to Prolog. Indeed, I would have thought it especially _easy_ to add such features to well-designed dynamic languages.