>From mira@ccs.neu.edu Mon Nov 3 10:03:51 1997 >Received: from taboor.ccs.neu.edu (mira@taboor.ccs.neu.edu [129.10.112.115]) > by amber.ccs.neu.edu (8.8.6/8.7.3) with ESMTP id KAA10319 > for ; Mon, 3 Nov 1997 10:03:50 -0500 (EST) >From: Mira Mezini >Received: (mira@localhost) > by taboor.ccs.neu.edu (8.8.6/8.6.4) id KAA11979 > for lieber@ccs.neu.edu; Mon, 3 Nov 1997 10:03:50 -0500 (EST) >Message-Id: <199711031503.KAA11979@taboor.ccs.neu.edu> >Subject: Re: examples in Rondo style >To: lieber@ccs.neu.edu (Karl Lieberherr) >Date: Mon, 3 Nov 1997 10:03:49 -0500 (EST) >In-Reply-To: <199710312238.RAA10194@stockberg.ccs.neu.edu> from "Karl Lieberherr" at Oct 31, 97 05:38:16 pm >X-Mailer: ELM [version 2.4 PL23beta2] >MIME-Version: 1.0 >Content-Type: text/plain; charset=US-ASCII >Content-Transfer-Encoding: 7bit >Status: R > >> Hi Mira: >> >> does this look good? >> >> strategies >> S1 = from Foo to Y >> >> Foo { >> // a traversal method called average >> void average() do S1; >> } >> adjustment Count { >> (@ int total_count; @) >> init (@ total_count = 0; @) >> change (@ total_count++; call_super(); @) >> return (@ total @) >> } modifies Y >> >> adjustment Sum { >> (@ int total_sum; @) >> init (@ total_sum = 0; @) >> (@ total_sum+=value; call_super(); @) >> return (@ total @) >> } modifies Y >> >> adjustment Average { >> (@ int avg; @) >> change (@ System.out.println( total_sum/total_count ); >> } modifies Y >> >> Foo f = new Foo() modify average with {Count,Sum,Average}; >> f.average(); >> >> Alternatively we could say earlier: >> >> void average() do S1 with {Count,Sum,Average}; >> >> ================= > > >Hi Karl: > >yes, this looks very good. It looks pretty much similar to the >sample code I wrote down as you left on Friday except for the >following few modifications I have done below. >Please compare. > >// my modified code > > strategies > S1 = from Foo to Y > > Foo { > // a traversal method called average > void average() do S1; > } > adjustment Count { > (@ int total_count; @) > init (@ total_count = 0; @) > change (@ total_count++; call_super(); @) > return (@ total @) > } (*) > > adjustment Sum { > (@ int total_sum; @) > init (@ total_sum = 0; @) > change (@ total_sum+=value; call_super(); @) (**) > return (@ total @) > } (*) > > adjustment Average { > (@ int avg; @) > change (@ System.out.println( total_sum/total_count ); > } (*) > > > Sum modifies Foo; (*) > Count modifies Foo; (*) > Average connects Sum Count; (*) > > Foo f = new Foo() modify average with Average; (*) > f.average(); > > Alternatively we could say earlier: > > void average() do S1 with {Average}; (*) > >//end of modified code > > >What has chanched is the way "modifies" statements are done (*). >They are separated from the adjustment implementations, assuming >in this case that all three adjustments may be reused to mdify >several different base classes. >In addition I have prefered to declare Average as a connection >of Sum and Count. This simplifies the "modify average with ..." >statements. When Average gets activated the adjustments it >connects (Sum and Count) will be activated as weel. > >The second modification is (**) >-- the addition of "change" in Sum, which I guess you simply forgot. >I liked using this term ("change") for the methods to be attached to a >traversal. > > >> Here the container example: I got lost ... >> >> How do we refer to variables in other adjustments? >> >> We need to do this together. >> >> >> -- Karl > >I got lost too. I tried to understand your implementation in Dem/Java, >but I got kind of confused. I think, it's better to look at it >together. > > >-- Mira > > >PS.: Did you get my previous mail? Could you please tell me what they >sold me instead of Gregor's talk? That's really sad. Associating >viewgraphs with his voice would have been perfect. > >