News for hackers. Stuff that matters.
Re:Go Statement Considered Harmful (2018) by dragonwriter on Friday March 19, 2021 @03:58AM (#26510967)
> Smalltalk, Ruby, and other languages in a similar vein beg to differ. And I don't think you could call e.g. Smalltalk "unstructured", either.

Smalltalk, Ruby, and any language with callcc is nearly as unstructured as it would be with goto (though most of them idiomatically minimize usage, which mitigates this in practice), which is also a part (implementation/optimization prospects are another) that Ruby banished continuations from the core language to an MRI-bundled library starting way back with 1.9, replacing the main uses with the more structured Fibers.

Re:Go Statement Considered Harmful (2018) by dan-robertson on Friday March 19, 2021 @08:48AM (#26512647)
Callcc is pretty unstructured. Delimited continuations are a bit more structured and, to me, seem a useful primitive even if application code shouldn’t ever use them. Common Lisp has lexically scoped goto/return which can be useful. Example:

  (defun foo-find (foo x &key (test #'eql))
    (foo-iter foo (lambda (bar)
      (bar-iter bar (lambda (y)
        (when (funcall test x y)
          (return-from foo-find y)))))))
Some people try to implement something similar using exceptions but this only works if nothing swallows your special exception on its way up to the block you’re trying to return from.
Re:Go Statement Considered Harmful (2018) by dragonwriter on Friday March 19, 2021 @10:31AM (#26513758)
Sure, all of those (even callcc) are useful, and having them in an otherwise reasonably high-level language means you can use it to build plumbing in the language that would otherwise have to be primitives implemented in a lower-level language (e.g., the Common Lisp condition system, which is basically exceptions with superpowers, can be built fairly simply on top of call/cc; I once built a toy implementation for Ruby based on the one in Practical Common Lisp.)

I don't think having unstructured told in a language is a bad thing, though I think the core language / stdlib having the right structured tools (whether primitives or built in the language itself on top of the unstructured ones) that most code never needs to reach for the unstructured tools is desirable.

Re:Go Statement Considered Harmful (2018) by int_19h on Tuesday March 23, 2021 @10:08PM (#26562751)
I wasn't referring to call/cc tho, but rather to the ability of lambdas to "return" from the outer function/method. In Ruby, IIRC, you can also "break" etc.

This is completely orthogonal to call/cc, because it won't allow you to do this arbitrarily - you get an exception if there's nothing to return/break from anymore.