Best search algorithm to find condition within a range

Rustom Mody rustompmody at gmail.com
Fri Apr 10 18:39:25 CEST 2015


On Thursday, April 9, 2015 at 11:05:54 PM UTC+5:30, Steven D'Aprano wrote:
> On Fri, 10 Apr 2015 02:25 am, Marko Rauhamaa wrote:
> 
> > Chris Angelico:
> > 
> >> As far as it's concerned, it's impossible for a CPU register to
> >> arbitrarily change without notice. It's equally impossible for the
> >> addition of two positive signed integers to result in a negative
> >> integer.
> > 
> > The standard says that any program that takes a signed integer out of
> > its valid range is broken and deserves anything that happens to it.
> > 
> > I say it's the standard that is broken.
> 
> It's not so much the undefined behaviour part that gets me. That's bad
> enough. But the concept that having the compiler ignore what you write in
> the source code because you've accidentally hit some undefined part of the
> spec *is a feature* rather than a horrible, horrible design flaw that blows
> my mind.

There is something from Dijkstra (cant find the details ATM) that come to mind:

How should a programmer think of writing a program that contains an ∞ loop?
Imagine sitting in a room next to the computer... with no windows or doors...
Just the computer
When the programmer feeds the program to the computer he has to wait (that's WAIT) for the computer to print out the result before the  door opens.
And so if the machine 'hangs' so does the programmer!!

In short when you do what you shouldn't do, there's no limit to the penalty.

Dijkstra may strike many people as a nut, however I remember on the DOS machines
on which I grew up, if the program crashed so did the OS -- switching on/off
(the wall-plug!) was considered normal and acceptable behavior.
If you were not so lucky you could lose the contents of the disk.
And then there were horror stories of monitors getting fried by wrong refresh rates etc.



More information about the Python-list mailing list