GOTO w/ Python?

Carl Banks imbosol at vt.edu
Fri Jun 21 16:47:39 EDT 2002


John Roth wrote:
> At the time he designed the language, I suspect that if anyone had
> brought it up, he'd have been laughed out of the room. We're talking
> late 80's, early 90s here, not the '60s or '70s.

Perl was also designed late 80's, early 90's, but it does have goto in
it.  I doubt Larry Wall was ever laughed out of a room.

Then again, one of the Perl manpages presents this as an "interesting
approach to a switch statement":

$amode = do {
    if     ($flag & O_RDONLY) { "r" }       # XXX: isn't this 0?
    elsif  ($flag & O_WRONLY) { ($flag & O_APPEND) ? "a" : "w" }
    elsif  ($flag & O_RDWR)   {
        if ($flag & O_CREAT)  { "w+" }
        else                  { ($flag & O_APPEND) ? "a+" : "r+" }
    }
};

So maybe these people thought goto was a little boring.

:)


-- 
CARL BANKS                                http://www.aerojockey.com
"Nullum mihi placet tamquam provocatio magna.  Hoc ex eis non est."



More information about the Python-list mailing list