From: Florian Gross Date: 2005-02-17T22:29:52+09:00 Subject: Re: DesignByContract (was RE: utilizing ++ and -- for comments) gabriele renzi wrote: >> Wondering if you have a way to do these ... >> >> How would the check :pre get access to the method parameters? >> >> And how would the check :post access the return, or the params, or the >> initial values (instance vars etc.)? > > I guess florian would overwrite the method #pop with a new one which > does bot the pre-code and the original code. Mauricio Fernandez showed a > nice approach to this which did not need eval() quite a long time ago > (even if he presented it as poor man's AOP) This would be the basic way of doing it -- note that I'm not sure about having pre-checks access to arguments -- after all the signature is for ensuring the basic consistency of those. It would still be nice to have them, though. Regarding in-variants: I'll probably end up wrapping all methods like with the pre/post checks and having a method_added hook for wrapping newly added methods as well. I've not thought about all the details (what about inheritance) and so on yet -- it will probably be easier for me to think about those once I have a basic implementation I can toy with.