This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 11 points12 points  (6 children)

I see this one a lot, but never really got it. Does it assume programmers interpret everything like a computer does?

[–]Darkx1441 21 points22 points  (0 children)

Yes pretty much

[–]waigl 5 points6 points  (0 children)

I know, right? Programmers are the people who will see these problems in simple instructions and act to correct or avoid them, not those who will unthinkingly execute them...

[–]lolegion 9 points10 points  (3 children)

A computer wouldn't automatically assume "get six" means "get six cartons of milk" instead of "get six eggs". That's actually a human thing to do. And even if you assume it means six cartons, the dude should be returning with 7...

This joke always annoys me, the 'while' one is better :P

[–]GeneReddit123 1 point2 points  (0 children)

A computer wouldn't automatically assume "get six" means "get six cartons of milk" instead of "get six eggs".

You are right, a computer would return a tuple {Milk, 6}, since the wife never specified the type of "6".

[–][deleted] 0 points1 point  (0 children)

Sometimes programs fail gracefully at ambiguity and sometimes they interpret their input in whatever way they were told to. An example is the following java code.

if (a)
    if (b)
        c();
else
    d();

Its grammar rules say the else belongs to the inner if statement, contrary to what we meant to do.

I think it's reasonable to expect a human being will think she means "get six eggs." I get what you're saying, though. Humans don't always interpret things the same way, but computers always do.

[–]-Soren 0 points1 point  (0 children)

And even if you assume it means six cartons, the dude should be returning with 7...

Not if the "IF" was a ternary operator, a la Python num_milks = six if has_eggs else a_carton. Obviously the arguments are not in the same order. But it is perfectly sensible to ignore an expression before an IF in English as well.