About foreach loops

Jesse Phillips jessekphillips+d at gmail.com
Sun Jun 19 18:55:10 PDT 2011


On Sat, 18 Jun 2011 02:21:19 +0000, Timon Gehr wrote:

> You have two classes of items.
> 
> 1. Tea Cups. Dropping them to the floor will break them. 2. The magical
> flubber slime ball from outer space (TMFSBFOS). Dropping it to the floor
> will have undefined behavior.
> 
> Now you have a set of equal boxes, each containing either a Tea Cup or
> the magical flubber slime ball from outer space. You have no way to know
> what it is.
> ...
> Cheers,
> -Timon

I really like the analogy you have set up. So let us define what happens 
when we drop the box.

My position is that you can not define the resulting behavior.

You claim that if the Tea Cup is in the box, the Tea Cup will break.

I can agree that this will be what happens, but I can not define for you 
what dropping the box will do.

But if the box were to be dropped with a Tea Cup was inside, and the Tea 
Cup turned into a whale, then it would still fulfill the spec, yet I can 
not provide for you a way that dropping a boxed Tea Cup could result in 
anything but a broken Tea Cup.


More information about the Digitalmars-d mailing list