5 ms·
Doesn't the post stumble over right in the second section? "It is not possible to create a Go program where two variables share the same storage location in mem
by htns 9y ago
Doesn't the post stumble over right in the second section? "It is not possible to create a Go program where two variables share the same storage location in memory". So what? The C example didn't show that either.
- lvh 9y agoYou are correct that C also does not have pass-by-reference. However, the second listing is a C++ program, not a C program, and C++ very much has pass-by-reference. The C++ program demonstrates true aliases, as you can tell from the output of the printf (see comment on same line).
- htns 9y agoI have always found that is conflating the semantics of using with the method of passing. Even with/out aliases you are still passing a reference.
- lvh 9y agoI don't think that's accurate. I can pass something locally declared as int to a fn that takes int& according to it's signature. It seems that's precisely what the confusion is about :)