News for hackers. Stuff that matters.
Re:Ask HN: What ideas in programming languages do you find d... by Const-me on Monday October 23, 2017 @10:21AM (#15533333)
I think the challenge is quadratic growth of complexity with state size.

Here’s an example of FSM with relatively complex state, 1000-lines gc_execute_line function, it’s for CNC: https://github.com/grbl/grbl/blob/master/grbl/gcode.c

That’s not my code, but I’m not sure I would be able to do much better than that.

Re:Ask HN: What ideas in programming languages do you find d... by Jtsummers on Monday October 23, 2017 @11:00AM (#15533648)
That code actually has me a bit confused. I don't understand how this part is working:

  switch(letter) {
    case 'G':
      switch(int_value) {
        case 4:
          switch(int_value) { // int_value hasn't changed
            case 10: ...      // so how do we get to this case?
That second switch on int_value is at line 151. Have I missed something in the code where int_value is changing?
Re:Ask HN: What ideas in programming languages do you find d... by Const-me on Monday October 23, 2017 @12:04PM (#15534187)
It’s not changing.

However, above that “case 4:” there’re another cases, “case 10: case 28: case 30: case 92: ” without break at the end of the code. Unlike some other languages, in C and C++ this means execution continues to the next case. The behavior is called "switch statement fallthrough".

That source code has the comment saying “No break. Continues to next line.”

Re:Ask HN: What ideas in programming languages do you find d... by Jtsummers on Monday October 23, 2017 @12:18PM (#15534305)
Ah, I missed that they didn't break above it. Thanks.