▲ | jll29 6 days ago | |
Thanks for sharing. Not knowing Odin's syntax yet, having had a quick look at the code, a few things are strange: Are there two types of assignment?
What should this mean? The comma notation usually indicates a pair or left-to-right control flow (Python and C, respectively), but why (appear to) assign a pair to itself?
This probably means something else, but it reads odd.
If Odin is so similar to C, what are the "dark corners" where it outshines it? | ||
▲ | krig 6 days ago | parent [-] | |
> Are there two types of assignment? > > p1[0] = 0 > ... > n := 0 >What should this mean? The comma notation usually indicates a pair or left-to-right control flow (Python >and C, respectively), but why (appear to) assign a pair to itself? This probably means something else, but it reads odd. = is assignment and := is assignment and declaration.
You can explicitly give the variable a type by adding it before the =
There is also :: for constants.> car, cdr := car, cdr Odin has multiple assignment like Python, so this is a swap without temporary. edit: No, it isn't! Didn't read carefully. Swap would be
This one is because parameters are immutable in Odin, so to get a mutable copy in the function we have to declare it.> If Odin is so similar to C, what are the "dark corners" where it outshines it? Off the top of my head: - No undefined behaviour - Builtin string type, dynamic array type, slices - Builtin map type - Excellent tooling for 3D math: swizzling, matrix math, array programming - Bounds checking - Tooling for memory management: leak detection, temp allocator, arena allocators - Builtin unit test framework - Tagged unions with exhaustiveness checked switch statement - for ... in loop syntax |