Hendrik van Rooyen wrote:
> "Donn Cave" <[EMAIL PROTECTED]> wrote:
> 
>> In its day, goto was of course very well loved.
> 
> Does anybody know for sure if it is in fact possible to
> design a language completely free from conditional jumps?
> 
> At the lower level, I don't think you can get away with
> conditional calls - hence the "jumps with dark glasses",
> continue and break.
> 
> I don't think you can get that functionality in another way.
> 
> Think of solving the problem of reading a text file to find
> the first occurrence of some given string - can it be done 
> without either break or continue?  (given that you have to 
> stop when you have found it)
> 

Pascal has no break, continue or return. Eiffel doesn't even have a 
goto. In such imperative languages boolean variables are used a lot.

from StringIO import StringIO
lines = StringIO("one\ntwo\nthree\nfour\n")
line_number = 0
eof = False
found = False
while not (eof or found):
        line = lines.readline()
        eof = line == ""
        found = line == "three\n"
        if not found:
                line_number += 1

                
if found:
        print "Found at", line_number
else:
        print "Not found"
# prints "Found at 2"

---
Lenard Lindstrom
<[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to