3 ms·
Actually, not all Go types are nilable. Integers and strings; those things aren’t nilable. Pointers, interfaces, slices, and some other stuff is. I’m new to Go
by ok_dad 4y ago
Actually, not all Go types are nilable. Integers and strings; those things aren’t nilable. Pointers, interfaces, slices, and some other stuff is. I’m new to Go so I don’t remember the rules exactly, but you can look up the exact details I’m sure.
- masklinn 4y ago> Integers and strings; those things aren’t nilable. Which is then annoying because if you want an optional integer you now need a pointer, and a heap allocation.
- convolvatron 4y agodoes anyone else think Go would be a much better language without the pointer distinction? maybe an explicit mutable type modifier instead?
- ok_dad 4y agoYea, I think references to other values should be a type, like a `Reference[T]`. Then you can pass something by reference, rather than value, without having confusing referencing/dereferencing. A `Reference[T]` could have some sort of element reflection, where you can just use it like it's a `T`. Pointers, referencing, dereferencing; that can get confusing even for skilled engineers.
- ok_dad 4y agoThat's one of the most annoying things to me coming from Python: the inability to have a default argument value.
- ecnahc515 4y agoGo can use escape analysis to determine if a heap allocation is actually required in some cases.