5 ms·
Perhaps the author was inspired by the Go language, as those are both Go-isms: Go's only loop is a for loop, and := tells the compiler to infer the variable typ
by notduncansmith 11y ago
Perhaps the author was inspired by the Go language, as those are both Go-isms: Go's only loop is a for loop, and := tells the compiler to infer the variable type when initializing.
In fact, this snippet is only a few deviations away from being valid Go code.
- AYBABTME 11y agoTheir compiler is written in Go. See https://github.com/ark-lang/ark https://github.com/ark-lang/ark
- warmwaffles 11y agoYou also need to remember that at one point Go's compiler was written in C, as with rust. It's all apart of the language evolution.
- AYBABTME 11y agoI'm not blaming them, just saying there's evidence the authors are quite familiar with Go. =P
- fapjacks 11y agoIndeed it is written in Go, after all.
- michaelmior 11y ago:= isn't really stating to infer the type (although this happens) but a way to differentiate variable initialization with assignment. When using := the variable is created while = is just a regular assignment. Having these as separate operators prevents errors like this: foo := 3 fooo = 4 The second line is invalid because fooo does not exist.