I’m just learning Julia, and I’m finding the docs not so clear on the differences between type and struct. In the docs there are no real examples of declaring custom types using the type keyword, instead there’s a section on composite types using struct. So I’m just pointing out that as a beginner the docs are leaving me with questions:
What is the difference between using struct and type, or mutable struct and type?
Why would you choose one over the other? Why is struct used in the docs rathe than type?
I will not comment on the aesthetic part (I happen to like struct), but note that “type” is used in another, very specific sense by Julia (the thing that dispatch operates on, etc), so using it for composite types was just confusing.
No, when the docs are talking about the concept of a type, then it doesn’t change (and this was a big part of why the change was necessary, the confusion when talking about a specific kind of type, i.e. a structure that might be mutable or immutable, vs. abstract types, primitive types, etc., or talking about the concept).
In your code (but not in any doc strings discussing the concept ), yes, replace immutable => struct, and type => mutable struct.
OK, I see your point, that is a bit unclear.
I believe, when it says “all objects are instances of”, simply means that the release isa Any is always for any object. (isa being true for instances of a particular type or subtype of the given type), so not really contradictory.
So, 1 is an instance of an Int, and it’s an instance of a Signed type, an Integer type, a Number type, and Any.