Earlier quoted context omitted.
Please let me know what's plain wrong; I'm always happy to receive constructive feedback.
The beginning item about if-else returns isn't go-specific and is low impact, and immediately turned me off / led me to dismiss the article as a waste of time. After trudging through more of the list, you've collected a lot of good nuggets! Maybe move the if-else to the end, as it's not particularly insightful compared to the rest. Also the shadowing, it's fine but much less interesting and unlikely to hook in your t…
Go structs are copied on assignment (and other things about Go I'd missed)
171–176 of 176 posts
Re: Go structs are copied on assignment (and other things about Go I'd missed)
#172Earlier quoted context omitted.
Technically no, but I get why it feels like this. :-) I think the confusion stems from the fact that Go hides the distinction of "dot" access vs "pointer dot" access. (eg, the difference between `foo.Bar` and `foo->Bar` in C++). Go knows if an object is a pointer and needs to be de-referenced, and hides the de-reference operation from you syntactically. So you can use a pointer without knowing it's a pointer. This is…
From Google's Go project blog: > Map types are reference types, like pointers or slices. https://go.dev/blog/maps
https://go.dev/play/p/-mEeg2Ud68V
This example cannot re-allocate the original map! If the map were truly passed by reference, it could be allocated in a local function. But it can't, only values within the map can be modified when a map is passed.
This is in contrast with pass by reference in, say, C++, in which case you can assign directly to and modify the reference. ex: https://www.ibm.com/docs/en/zos/2.4.0?topic=calls-pass-by-re...
Re: Go structs are copied on assignment (and other things about Go I'd missed)
#173Earlier quoted context omitted.
It's very clear that the reason these kinds of proposals haven't been accepted has nothing to do with the core team not believing they're important enough, but instead because of the impact that they have on the rest of the language.
What impact in your opinion?
Re: Go structs are copied on assignment (and other things about Go I'd missed)
#174Earlier quoted context omitted.
What impact in your opinion?
Immutability is a fundamental property of a language, it's not something that can be bolted on post-facto in a version update. Go as a language doesn't provide immutability.
Go provides certain immutability.
Re: Go structs are copied on assignment (and other things about Go I'd missed)
#175Earlier quoted context omitted.
Immutability is a fundamental property of a language, it's not something that can be bolted on post-facto in a version update. Go as a language doesn't provide immutability.
If the "for ;;" loop semantics can be bolted on post-facto in a version update, nothing else couldn't. Go provides certain immutability.