In a ground combat scenario, autonomous weapons could be a good thing. Right now, soldiers are tasked with protect others as well as themselves, and in most situations the safest resolution is to kill the antagonist. A machine or robot wouldn't suffer from emotional lapses in judgment (anger, hostility). A robot may have better weapons skills, so instead of a kill shot, may only need to wound. A robot would be more willing to put itself in harms way to protect a living person.
The programming required for such a machine would be incredibly complex, but controllable with defined precision. A human soldier can't be controlled or programmed, and history shows that humans make a lot of bad decisions when it comes to the use of deadly force.
In any problem, if you find yourself doing an infinite amount of work, the answer may be obtained by inspection.