[Numpy-discussion] Python needs goto

Anne Archibald archibald at astron.nl
Fri Sep 25 12:27:50 EDT 2015


goto! and comefrom! Together with exceptions, threads, lambda, super,
generators, and coroutines, all we're lacking is
call-with-current-continuation for the full list of impenetrable
control-flow constructs. Oh, and lisp-style resumable exception handling.
(Suggested syntax: drop(exception, value) to return control to where the
exception was raised and make the raise statement return value.)

On Thu, Sep 24, 2015 at 8:42 PM Charles R Harris <charlesr.harris at gmail.com>
wrote:

> On Thu, Sep 24, 2015 at 12:13 PM, Yarko Tymciurak <yarkot1 at gmail.com>
> wrote:
>
>>
>>
>> I think there are more valid uses - I've read that "goto" basically is
>> what a state machine does.
>> Have a read of the brief implementation notes for "goto" in golang, for
>> example.  Goto may not be unreasonable to use, just most people would
>> abuse.  Sort of like "everyone shouldn't write assembly, but if you
>> understand the machine, you can make good things happen".  Without
>> compiler/interpreter checks, more responsibility rests on the coder to keep
>> out of trouble.
>>
>
> I would agree about state machines. When implemented using the standard
> control flow constructs they always look a bit artificial.
>
>
That depends what your "standard" control flow constructs are. Has anyone
tried implementing a state machine using coroutines? They seem like a
rather natural setup: each state is a coroutine that loops, doing the
appropriate actions for the state and then handing control over to the
coroutine for the next state.

Anne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150925/5a114ce1/attachment.html>


More information about the NumPy-Discussion mailing list