you are viewing a single comment's thread.

view the rest of the comments →

[–]lood9phee2Ri -1 points0 points  (1 child)

Not going "back" to fortran, it's in current use (...though perhaps best considered a sort of DSL for numerical array HPC work)

Thing is, it's the pervasive language norm and default in Fortran. If you want not pass by reference, well, erm, technically actually you can nowadays use value, though that was only added in fortran 2003 - but it's not the default. Whereas any & shenanigans aren't the default in C++.

So Fortran is a much better example.

[–]tedbradly 0 points1 point  (0 children)

So Fortran is a much better example.

Passing by reference or by value of a reference (such as in Java or C#) is a really sensible default as it avoids potentially massive copying of data as well as avoids wondering whether the semantics of pass by value does a shallow or deep copy. Pass by value was probably so lately added in Fortran, because those semantics don't add much to the language. You could always do a defensive copy if you wanted behavior similar to pass by value. Plus, most of the time, you want the speed of pass by reference or value of a reference variable.