4 ms·
I mean compare to using arrow functions and it's almost identical let decrement = () => set_value.update((value) => value -1); The difference is that Rust
by duped 4y ago
I mean compare to using arrow functions and it's almost identical
let decrement = () => set_value.update((value) => value -1);
The difference is that Rust isn't garbage collected and has reference value semantics, which is where the *value -= 1 comes in.
- willio58 4y agoIt's funny, I almost noted that arrow functions are a definite oddity of JS that I could see people thrown off by.
- marcosdumay 4y ago> oddity of JS I can't think on any modern language that lacks some short syntax for lambdas. Hell, it's very easy to make a point that lacking short syntax for lambdas make a language not modern and unusable for our current standards.
- willio58 4y agoI'm a little confused what you mean by JS lacking a short syntax for lambdas. let multiply = (a, b) => a * b; Is this not a lambda?
- kaba0 4y agoParent means that basically every language has lambdas, so it could hardly be an odd thing.
- willio58 4y agoOhh! Thanks for clarifying
- earthling8118 4y agoYou've missed their point entirely. It was never stated that JS was lacking this, rather than most languages DON'T lack it.
- ansc 4y agoI like how you skipped the hardest part that requires most Rust knowledge; the `move`
- duped 4y agoOk fine, "Rust doesn't have a garbage collector and has reference value semantics and ownership semantics." My point is that the syntax isn't a problem, it's that Rust has very different semantics from the GC'd languages in the original comment and it all has to do with memory management.