Skip to content

Commit

Permalink
stop using pass by reference in noteworthy difference (#26427)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Mar 13, 2018
1 parent 46dcb35 commit 7beb110
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/src/manual/noteworthy-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ major syntactic and functional differences. The following are some noteworthy di
may trip up Julia users accustomed to MATLAB:

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

0 comments on commit 7beb110

Please sign in to comment.