This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Some questions about GOOPS and CLOS in general


>>>>> "Klaus" == Klaus Schilling <Klaus.Schilling@home.ivm.de> writes:

Klaus> Eric Moore writes:
>>  Ok, as an example I'll use a newtonian mechanics (say molecular
>> dynamics or planetary motion) simulator.  We will at each time
>> step, cause pairs of bodies to interact.  The interactions will be
>> equal and opposite, affect both bodies, and depend on the
>> characteristics of both.
>> 
>> Using a goops-like design, you might have a method that dispaches
>> on something like:
>> 
>> (interact a b)
>> 
>> which will update the accelerations of both a and b, that is, it
>> will have side effects on both.
>> 
>> In C++ or java you could either use something like:
>> 
>> a.interact(b); b.interact(a);
>> 
>> Or
>> 
>> a.interact(b);
>> 
>> with the latter having side-effects on b, which you (if I've
>> followed things correctly) consider bad.

Klaus> In the Jost B.-Approach, there will be a class Interaction
Klaus> neither modifying a nor b

Now what use would that be? we're trying to update the momentum of a
and b, so that we can get the positions in the next time-step.  I was
trying to answer the question of what was meant by a desireable
side-effect.  I guess that in that approach the solution would be:

Interaction i = new Interaction(a,b);
a.modifyBy(i);
b.modifyBy(i);

This is getting pretty odd looking, and I don't particularly see why
it's better than a.interact(b); b.interact(a); especially if a and b
belong to different clases.  In any case, I was merely trying to
demonstrate a case where it might be beneficial to have side effects
on multiple arguments, and I'm not convinced that the existance of
another way of doing things invalidates that.

  -Eric


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]