Julia function argument by reference

前端 未结 4 1562
抹茶落季
抹茶落季 2021-02-05 08:22

The docs say

In Julia, all arguments to functions are passed by reference.

so I was quite surprised to see a difference in the behav

4条回答
  •  太阳男子
    2021-02-05 09:18

    I think the document is a bit vague here.

    Strictly speaking, Julia is "call-by-value where the value is a reference" , or "call-by-sharing", as used by most languages such as python, java, ruby, js... See wiki

    A call by reference behaviour would indeed make foo! to change the zeros to ones. However Julia doesn't support that. (If you know C#, that is what ref or out does)

提交回复
热议问题