Skip to content

Commit 7beb110

Browse files
authored
stop using pass by reference in noteworthy difference (#26427)
1 parent 46dcb35 commit 7beb110

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

doc/src/manual/noteworthy-differences.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ major syntactic and functional differences. The following are some noteworthy di
77
may trip up Julia users accustomed to MATLAB:
88

99
* Julia arrays are indexed with square brackets, `A[i,j]`.
10-
* Julia arrays are assigned by reference. After `A=B`, changing elements of `B` will modify `A`
10+
* Julia arrays are not copied when assigned to another variable. After `A = B`, changing elements of `B` will modify `A`
1111
as well.
12-
* Julia values are passed and assigned by reference. If a function modifies an array, the changes
12+
* Julia values are not copied when passed to a function. If a function modifies an array, the changes
1313
will be visible in the caller.
1414
* Julia does not automatically grow arrays in an assignment statement. Whereas in MATLAB `a(4) = 3.2`
1515
can create the array `a = [0 0 0 3.2]` and `a(5) = 7` can grow it into `a = [0 0 0 3.2 7]`, the
@@ -153,7 +153,7 @@ For users coming to Julia from R, these are some noteworthy differences:
153153
* Julia encourages users to write their own types, which are easier to use than S3 or S4 objects
154154
in R. Julia's multiple dispatch system means that `table(x::TypeA)` and `table(x::TypeB)` act
155155
like R's `table.TypeA(x)` and `table.TypeB(x)`.
156-
* In Julia, values are passed and assigned by reference. If a function modifies an array, the changes
156+
* In Julia, values are not copied when assigned or passed to a function. If a function modifies an array, the changes
157157
will be visible in the caller. This is very different from R and allows new functions to operate
158158
on large data structures much more efficiently.
159159
* In Julia, vectors and matrices are concatenated using [`hcat`](@ref), [`vcat`](@ref) and
@@ -227,13 +227,13 @@ For users coming to Julia from R, these are some noteworthy differences:
227227
This syntax is not just syntactic sugar for a reference to a pointer or address as in C/C++. See
228228
the Julia documentation for the syntax for array construction (it has changed between versions).
229229
* In Julia, indexing of arrays, strings, etc. is 1-based not 0-based.
230-
* Julia arrays are assigned by reference. After `A=B`, changing elements of `B` will modify `A`
230+
* Julia arrays are not copied when assigned to another variable. After `A = B`, changing elements of `B` will modify `A`
231231
as well. Updating operators like `+=` do not operate in-place, they are equivalent to `A = A + B`
232232
which rebinds the left-hand side to the result of the right-hand side expression.
233233
* Julia arrays are column major (Fortran ordered) whereas C/C++ arrays are row major ordered by
234234
default. To get optimal performance when looping over arrays, the order of the loops should be
235235
reversed in Julia relative to C/C++ (see relevant section of [Performance Tips](@ref man-performance-tips)).
236-
* Julia values are passed and assigned by reference. If a function modifies an array, the changes
236+
* Julia values are not copied when assigned or passed to a function. If a function modifies an array, the changes
237237
will be visible in the caller.
238238
* In Julia, whitespace is significant, unlike C/C++, so care must be taken when adding/removing
239239
whitespace from a Julia program.

0 commit comments

Comments
 (0)