| > 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. x := 1 // create a new variable x with the value 1
x = 2 // assign 2 to x
y = 3 // error: y does not exist
You can explicitly give the variable a type by adding it before the = x : u8 = 1 // a one byte unsigned integer with the value 1
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 car, cdr = cdr, car
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 |