1. 32

  2. 9

    It brought us such revolutionary innovations as null, a value that crashes your program.


    1. 3

      ML-style freedom from null is the optimal scenario IMO. But, to be fair, among languages that have null, some handle it more gracefully than others. For instance, Common Lisp’s NIL (similarly Python’s None, Ruby’s nil, etc.) is nicer than Java’s null, since NIL is an actual object, it has a class, etc.

    2. 5

      it seems odd to include Rust here. it clearly has pattern matching a la ML, which really isn’t the same thing as a switch statement.

      1. 3

        Pattern matching isn’t exactly switch, but they have enough in common for the comparison to be meaningful: both are selection constructs, both can handle arbitrarily many cases, both have evolved considerably since they were first invented. Other alternatives to switch are mentioned as well, although they constitute less radical departures from the original concept.

      2. 4

        I’m very impressed with Perl 6’s implementation of switch. I really like how the three components of a switch are general, and can be used separately.

        1. 3

          I’m amazed.

          I searched.

          No mention of protothreads.


          You see, switch statements are orthogonal to everything else in C.

          And once you have a truly evil idea like that, you can take it all far too far….

          1. 3

            Why/how does Contiki take it too far? I’ve never had an excuse to dig into it, and didn’t see anything obvious you were getting at.

            1. 2

              Well, if you came across a LARGE function that had a switch statement at the beginning with cases INSIDE if statements, else branches, for loops, while loops, …

              You’d be a trifle disconcerted.

              If the author then wrapped it in layers of macro magic….

              And made a whole blooming multithreaded RTOS out of it… you feel…. ahh. Gee, Wow! That was impressive evil!

          2. 4

            Would’ve been interesting to evaluate Go, which claims descendance from both algol and c. Here the break statement is gone, instead each case block is evaluated only once. The special keyword “fallthrough” is added to merge logical case blocks together, the previous default behaviour for C. Each case is now an expression too. As with most things Go, not revolutionary.

            more here: https://golang.org/ref/spec#Switch_statements

            switch tag {
                default: s3()
                case 0, 1, 2, 3: s1()
                case 4, 5, 6, 7: s2()
            switch x := f(); {  // missing switch expression means "true"
                case x < 0: return -x
                default: return x
            switch {
                case x < y: f1()
                case x < z: f2()
                case x == 4: f3()
            1. 2

              I really enjoy “where did this come from” things about programming languages. For a while now I’ve wanted a book (or website) along the lines of Cajori’s A History Of Mathematical Notations