News for hackers. Stuff that matters.
Re:Resource efficient Thread Pools with Zig by fiddlerwoaroof on Monday September 13, 2021 @11:09PM (#28519764)
The thing that really surprised me about Rust is the significance of a semicolon at the end of a function body. E.g.:

    fn foo { 1; }
Returns unit while

    fn foo { 1 }
Returns 1. This reminds me of nothing so much as the infamous JavaScript ASI footgun where this returns undefined:

    function foo() {
      return
      2;
    }
Re:Resource efficient Thread Pools with Zig by c-cube on Tuesday September 14, 2021 @08:06AM (#28523434)
It's not just the function's body, it's any block. Blocks in rust are expressions and return their last statement's value. It's nothing like Javascript's ASI where it's just inserting ; implicitly and only `return` can return a value.
Re:Resource efficient Thread Pools with Zig by burntsushi on Saturday September 18, 2021 @06:57PM (#28580098)
It's also nothing like Javascript because Rust is statically typed. If you accidentally insert a semi-colon (or not), you're almost guaranteed to get a compile error.
Re:Resource efficient Thread Pools with Zig by adamnemecek on Sunday September 19, 2021 @04:34PM (#28587682)
The second function is a syntax error since you are not declaring the return value in the function signature.