From: Ryan Pavlik Date: 2003-11-22T09:03:40+09:00 Subject: Method combination On Sat, 22 Nov 2003 08:37:03 +0900 matz@ruby-lang.org (Yukihiro Matsumoto) wrote: > > |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. Lisp has (call-next-method &rest args) used in method combination... I'm not sure how things have been proposed (I only saw the slide), but: def foo:pre(a,b) call_next unless (a > b) end def foo(a, b) return "OK" if (a < 15) call_next(a+b) end def foo:post(x) : end def foo:wrap(a,b) # blah blah res = call_next(b, a) # Might get "OK"? or whatever :post returns.. # blah blah end Again, I'm not sure how you want everything to flow exactly. With 'call_next', the ability to call it or not is both an advantage and a disadvantage. -- Ryan Pavlik "Now if you'll excuse me, I've got to single-handedly save a film genre." - 8BT