I just started looking a Julia. I'm interested in how it accomplishes multiple dispatch, specifically how it determines the type for use in multiple dispatch.
In the introduction to Types,the manual states:
all values in Julia are true objects having a type that belongs to a single, fully connected type graph, all nodes of which are equally first-class as types
My question is: How is the type graph connected?
For example, where would an Array
of Integer
s fit in? Is it a subtype of Array
or a subtype of Integer
? Both?
How 'bout Complex
numbers? Can I have Array
s (2x1) of Rational
and Duples
(2-Tuples) of Integers
both be Complex
?
# This is my first Julia code ever. It is probably wrong.
abstract type Rational <: Number end
abstract type Integer <: Rational end
abstract type Complex <: Array{Integer, 2} end
abstract type Complex <: Tuple{Rational, Rational} end
(1, 2)::Complex * (1, 2)::Complex
In the above two examples, I'm using "code font"
to denote abstract types.
Maybe the code example is the "wrong" concept? Maybe I should define a "multiply complex" function in stead?
Can you show me a drawing of the type graph for the built-in types?