1. 8
  1. 3

    The author’s nursery construct seems fine but they really don’t need to make this poor comparison between go and goto.

    For example:

    That’s right: go statements are a form of goto statement.

    Hrm? go is a control flow construct just like goto, just like while and just like for. All control flow constructs can be drawn with arrows going in different directions. How this makes go like in the way the author wants goto is really unclear. The author goes through a lot of history of goto but with go you cannot jump to an arbitrary label like you can with goto, so that doesn’t make them sound similar. Does the author not like function calls as well? Why does the author like exceptions, since they are much closer to goto than go.

    Before, we said that we were “guaranteed” that the file will be open while the … code is running, and then closed afterwards. But what if the … code spawns a background task? Then our guarantee is lost: the operations that look like they’re inside the with block might actually keep running after the with block ends, and then crash because the file gets closed while they’re still using it.

    But with doesn’t actually give you any better guarantee. For example I can do:

    foo = []
    with open(somefile, 'r') as f:
        foo.append(f)
    
    foo[0].read()
    

    You have this problem anywhere you pass the value you’ve created with with to something else. This is no different than the claim the author makes about background tasks.

    Finally, start_soon has the same control flow arrows as go, and what the nursery does can be implemented in lots of languages, Python isn’t doing anything special or more powerful there. That isn’t to say doesn’t look like a valuable construct but I think the author is making much more out of it than it actually is.

    1. 1

      This really seems like fork+join as a python context manager, which is just a bit of sugar on a pattern just about everyone has written.

      Also, this doesn’t solve the problem he claims it does: any thread of execution inside a nursery can still call fork or equivalent and have a thread of execution that outlives scope.

      1. 1

        This seems smart to me. I sometimes get annoyed manually using sync.WaitGroups in Go to get similar results manually.

        http://libdill.org/ seems to be the same idea for C, structured tree of concurrent processes.

        Stories with similar links:

        1. Notes on structured concurrency, or: Go statement considered harmful [2018] via idrougge 1 year ago | 35 points | 19 comments
        2. Notes on structured concurrency, or: Go statement considered harmful via adsouza 3 years ago | 25 points | 25 comments