How to pass an object by reference and value in Julia?

In Julia, functions always have pass-by-sharing argument-passing behavior: https://docs.julialang.org/en/v1/manual/functions/ This argument-passing convention is also used in most general purpose dynamic programming languages, including various Lisps, Python, Perl and Ruby. A good and useful description can be found here: https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing In short, pass-by-sharing works like pass-by-reference but you cannot change which value a binding in the … Read more

How to create a “single dispatch, object-oriented Class” in julia that behaves like a standard Java Class with public / private fields and methods

While of course this isn’t the idiomatic way to create objects and methods in julia, there’s nothing horribly wrong with it either. In any language with closures you can define your own “object systems” like this, for example see the many object systems that have been developed within Scheme. In julia v0.5 there is an … Read more

I have a high-performant function written in Julia, how can I use it from Python?

Assuming your Python and Julia are installed you need to take the following steps. Run Julia and install PyCall using Pkg pkg”add PyCall” Put your code into a Julia package using Pkg Pkg.generate(“MyPackage”) In the folder src you will find MyPackage.jl, edit it to look like this: module MyPackage f(x,y) = 2x.+y export f end … Read more

What is a “symbol” in Julia?

Symbols in Julia are the same as in Lisp, Scheme or Ruby. However, the answers to those related questions are not really satisfactory, in my opinion. If you read those answers, it seems that the reason a symbol is different than a string is that strings are mutable while symbols are immutable, and symbols are … Read more

Creating copies in Julia with = operator

The confusion stems from this: assignment and mutation are not the same thing. Assignment. Assignment looks like x = … – what’s left of the = is an identifier, i.e. a variable name. Assignment changes which object the variable x refers to (this is called a variable binding). It does not mutate any objects at … Read more