@@ -24,15 +24,15 @@ This will generate:
24
24
25
25
1 . An immutable struct ` S_Immut ` ;
26
26
2 . A mutable struct ` S_Mut ` ;
27
- 3 . Constructors for ` S ` that can create either the mutable or immutable version .
27
+ 3 . ` const S = Union{S_Immut{Y}, S_Mut{Y}} where Y ` .
28
28
29
29
It is then possible to create instances of the specified version:
30
30
31
31
``` julia
32
- julia> s1 = S (1 , 2 , 3.0 ; mutable = true )
32
+ julia> s1 = S_Mut (1 , 2 , 3.0 )
33
33
S_Mut {Int} (1 , 2 , 3.0 )
34
34
35
- julia> s2 = S (1 , 2 , 3.0 ; mutable = false )
35
+ julia> s2 = S_Immut (1 , 2 , 3.0 )
36
36
S_Immut {Int} (1 , 2.0 , 3.0 )
37
37
```
38
38
@@ -47,13 +47,8 @@ julia> @update s2.y = 3
47
47
S_Immut {Int} (1 , 3 , 3.0 )
48
48
```
49
49
50
- Importantly, there are some catches to keep in mind:
51
-
52
- - The constructors are backed by a dummy struct of the same name (e.g ` S ` in the example above) which means
53
- that it would be incorrect to dispatch on it. Use one of the versions of the structs or the abstract type
54
- instead;
55
- - For an immutable type, the mutation actually involve the creation of a new instance with
56
- [ Accessors.jl] ( https://github.com/JuliaObjects/Accessors.jl ) .
50
+ Importantly, for an immutable type, the mutation actually involve the creation
51
+ of a new instance with [ Accessors.jl] ( https://github.com/JuliaObjects/Accessors.jl ) .
57
52
58
53
59
54
## Contributing
0 commit comments