From: "T. Onoma" Date: 2003-11-22T20:36:18+09:00 Subject: Re: Method wrapper question (was "stereotyping (was ...)) On Saturday 22 November 2003 07:19 am, Gavin Sinclair wrote: > I'm not buying into the interface debate one way or the other, but a > related question here is: how do you envisage :pre, :post, etc., > working if they are defined multiple times? I have considered this too. I would like to propose an alternate/augmenting syntax that has a simple definite rule for how they work together: def dothis print "A" end def dothis pre print "B" post print "C" end dothis # => BAC def dothis pre print "E" post print "D" end dothis # => EBACD def dothis pre print "F" main print "Z" post print "G" end dothis # => FEZDG This final result might seem odd at first, but it is a very simple system. Every subsequent definition of a pre and/or post, causes the latter to become part of main. Thus every method has a pre, main and post once defined and every subsequent addition moves them a step inward to main. Another example, this time with : syntax. def dothis print "A" end def dothis:post print "B" end dothis # => AB def dothis:post print "C" end dothis # => ABC def dothis:main print "Q" end dothis # => QC def dothis print "Z" end dothis # => Z (still can redefine) What do you think? -t0