3
3
Types in Julia establish distinctions between different kinds of data,
4
4
and are used by the compiler to infer the intended use of those data.
5
5
Programming languages have traditionally employed one of two quite different type systems:
6
- static type systems,
7
- where expressions must have a computable type before the execution of the program,
8
- and dynamic type systems,
9
- where types are only computed at run time,
6
+ static type systems, where expressions must have a computable type before the execution of the program,
7
+ and dynamic type systems, where types are only computed at run time,
10
8
when the actual values manipulated by the program are available.
11
9
Statically typed languages typically offer faster execution,
12
10
at the cost of type annotations which must be explicitly added by the programmer.
@@ -26,14 +24,11 @@ All types belong to a single type tree, i.e. they are all at least related to th
26
24
User-defined types are treated the same as built-in types.
27
25
For additional flexibility, types can be defined as concrete, abstract or parametric.
28
26
Their relation to other types must be explicitly declared.
29
- One particularly distinctive feature of Julia's type system is that
30
- only abstract types can be used as supertypes for a family of related types.
27
+ One particularly distinctive feature of Julia's type system is that only abstract types can be used as supertypes for a family of related types.
31
28
Concrete types are final, and may not subtype each other.
32
- While this might at first seem unduly restrictive,
33
- it has many beneficial consequences with surprisingly few drawbacks.
34
- Both [ abstract types] ( #man-abstract-types ) and [ parametric types] ( #Parametric-Types )
35
- can be used to create flexible interfaces while leveraging method dispatch
36
- and mitigating type errors.
29
+ While this might at first seem unduly restrictive, it has many beneficial consequences with surprisingly
30
+ few drawbacks. Both [ abstract types] ( #man-abstract-types ) and [ parametric types] ( #Parametric-Types )
31
+ can be used to create flexible interfaces while leveraging method dispatch and mitigating type errors.
37
32
38
33
The methods [ ` isabstracttype ` ] ( @ref ) and [ ` isconcretetype ` ] ( @ref ) can be used
39
34
to check if a type is abstract or concrete.
@@ -613,8 +608,8 @@ julia> Point{AbstractString}
613
608
Point{AbstractString}
614
609
```
615
610
616
- ` Point ` itself is also a valid type object,
617
- containing all instances ` Point{Float64} ` , ` Point{AbstractString} ` , etc. as subtypes:
611
+ ` Point ` itself is also a valid type object, containing all instances ` Point{Float64} ` , ` Point{AbstractString} ` ,
612
+ etc. as subtypes:
618
613
619
614
``` jldoctest pointtype
620
615
julia> Point{Float64} <: Point
0 commit comments