[contest] Is a Cow an animal ++

BCS none at anon.com
Wed Sep 29 07:02:11 PDT 2010


Hello Simen,

> BCS <none at anon.com> wrote:
> 
>> The given test as is might be all catchable but add loops and
>> references  into the picture and I think it turns into the halting
>> problem.
>> 
> Would you mind explaining in further detail? I am not really sure what
> you mean.
> 

Cow c;
while(someFn()) {
  c = new Cow();
  c.slaughter();
}
c.slaughter(); // invalid Iff the loop ends

Cow c, d, r;
for(int i = 0; someFn(); i++) {
  c = new Cow();
  d = new Cow();
  r = (i%2) ? c : d;
  c.slaughter();
}
r.slaughter(); // invalid Iff the loop ends on an odd i.

void Fn(Cow c, Cow d) {
  c.slaughter();
  d.slaughter(); // invalid Iff called with (c is d).
}


Checking that the sequence of member function calls on an object is valid 
is limited by how good your static analysts is. The type system *can't* help 
you as the exact same code may or may not be valid depending on arbitrary 
external aspects.

-- 
... <IXOYE><





More information about the Digitalmars-d mailing list