Blessed Syntax and Ergonomics
16 points by gingerBill
16 points by gingerBill
C++ sadly does not make a distinction between [lvalue access] and [assignment], and has heavily suffered from this poor decision.
Wait a minute, what’s the problem with that? Call me naive, but, with lvalue access from the array, and assignment from the element, I should have all I need, right? I sense you have important use cases in mind, I’m guessing around performance, but I have no idea what they might be. Could you explain?
For a normal array, &[] would be the same as []=, but where it differs would be for something like a hash map. The behaviour of [] &[] and []= could all want to be different.
For example in Odin with Odin's map when the key does not exist, [] returns the zero value if it doesn't exist with an optional ok boolean as a multiple return value. &[] will return nil if the value does not exist, and []= will create the value if it does not exist.
In C++, the return value of T &operator[] for a hash map has to be a bit of a hack to even get insertion behaviour to work correctly.
Enforcing coding styles at the language-level rather than having it be a secondary vet pass
I can't tell if this is meant to be a tongue-in-cheek reference to go vet (which is essentially an optional linter): https://pkg.go.dev/cmd/vet
There are also a large number of third-party linters which are crowd-sourced (https://golangci-lint.run/docs/linters/). When you have hundreds of devs, you're going to enable some (in some folders only?) and not others. That list is going to vary from company-to-company, and maybe even folder-to-folder, depending on how much progress the associated cleanup made before the person who introduced a linter left the company.
It's more to do with Odin's -vet flag which can "vet" multiple different things for you, along with the per-file #+vet build flags:
-vet == -vet-unused -vet-shadowing -vet-deprecated -vet-cast
-vet-shadowing
-vet-unused
-vet-unused-imports
-vet-unused-variables
-vet-unused-procedures
-vet-style
-vet-semicolon
-vet-cast
-vet-tabs
-vet-packages
-vet-deprecated
But an external "linter" of sorts is honestly better most of the time. If you company/project wants to enforce that level of "linting", then you state which bits specifically.