That is the case for almost every modern language. C++ is one of the few languages that has "references" and at least last I looked that's a language accommodation over what are pointers being passed by value in the assembly, at least until compiler optimizations take over (and that's not limited to references either).
If you're in 2024 and you're in some programming class making a big deal about pass-by-value versus pass-by-reference, ask for your money back and find a course based in this century. Almost literally any topic is a better use of valuable class time than that. From what I've seen of the few unfortunate souls suffering through such a curriculum in recent times is that it literally anti-educates them.
For a last-century example of actual pass-by-reference, assign-by-copy, the PL/I program
foo: proc options(main);
dcl sysprint print;
dcl a(3) fixed bin(31) init(1,2,3);
put skip data (a);
call bar(a);
put skip data (a);
bar: proc(x);
dcl x(3) fixed bin(31);
dcl b(3) fixed bin(31) init(3,2,1);
x = b;
b(1) = 42;
x(2) = 42;
put skip data (b);
put skip data (x);
end bar;
end foo;
Sure, if they want to be bad developers in C#, F#, Swift, D, Rust, Ada, VB, Delphi, just to stay on the ones that are kind of relevant in 2024 for business, for various level of relevant, versus the ones story has forgotten about.
Maps and channels and functions are passed by reference. Slices are passed and returned by value but sometimes share state invisibly, the worst of both worlds. It would make more sense if Go either made this stuff immutable, made defensive copies, or refused and required using explicit pointers for all these cases.
No, it's not the case and this terminology shouldn't be used as it's confusing and unhelpful.
There are reference types in Go even though this is also not a super popular term. They still follow the pass-by-value semantics, it's just that a pointer is copied. A map is effectively a pointer to hmap data structure.
In the early days of Go, there was an explicit pointer, but then it was changed.
Slices are a 3-word structure internally that includes a pointer to a backing array and this is why it's also a "reference type".
That said, everything is still passed by value and there are no references in Go.
jerf|1 year ago
If you're in 2024 and you're in some programming class making a big deal about pass-by-value versus pass-by-reference, ask for your money back and find a course based in this century. Almost literally any topic is a better use of valuable class time than that. From what I've seen of the few unfortunate souls suffering through such a curriculum in recent times is that it literally anti-educates them.
jasomill|1 year ago
pjmlp|1 year ago
klyrs|1 year ago
metaltyphoon|1 year ago
azundo|1 year ago
Dylan16807|1 year ago
The important lesson is that assignments are by value(copy).
erik_seaberg|1 year ago
dondraper36|1 year ago
There are reference types in Go even though this is also not a super popular term. They still follow the pass-by-value semantics, it's just that a pointer is copied. A map is effectively a pointer to hmap data structure.
In the early days of Go, there was an explicit pointer, but then it was changed.
Slices are a 3-word structure internally that includes a pointer to a backing array and this is why it's also a "reference type".
That said, everything is still passed by value and there are no references in Go.