Skip to content

Commit 9b502ed

Browse files
authored
rename BoxConstField to BoxConst (#18)
1 parent 77c616b commit 9b502ed

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Exports these zero-dimensional subtypes of `AbstractArray`, differing on topics
1717
* declared with `mutable struct`
1818
* supports `setfield!` for mutating the element
1919
* acts as a reference to its element
20-
* `BoxConstField`
20+
* `BoxConst`
2121
* declared with `mutable struct`
2222
* does not support `setfield!`, or mutating the element otherwise
2323
* acts as a reference to its element
@@ -48,7 +48,7 @@ The motivation for creating this package is:
4848
* previous discussion:
4949
* https://github.com/JuliaLang/julia/issues/40369
5050
* https://discourse.julialang.org/t/dynamic-immutable-type/127168
51-
* To provide a [*boxing*](https://en.wikipedia.org/wiki/Boxing_(computer_programming)) feature, for example for data deduplication to avoid excessive memory use. Either `Box` or `BoxConstField` might be a good choice here, depending on whether mutability is desired. Compare:
51+
* To provide a [*boxing*](https://en.wikipedia.org/wiki/Boxing_(computer_programming)) feature, for example for data deduplication to avoid excessive memory use. Either `Box` or `BoxConst` might be a good choice here, depending on whether mutability is desired. Compare:
5252
* ```julia-repl
5353
julia> large_data = ntuple(identity, 8)
5454
(1, 2, 3, 4, 5, 6, 7, 8)
@@ -87,7 +87,7 @@ The motivation for creating this package is:
8787
0
8888
0
8989
```
90-
The other types, `Box` or `BoxConstField` would work for this use case, too, as would any zero-dimensional array, but `ZeroDimArray` is more likely to have zero cost for performance.
90+
The other types, `Box` or `BoxConst` would work for this use case, too, as would any zero-dimensional array, but `ZeroDimArray` is more likely to have zero cost for performance.
9191
* previous discussion regarding `Ref`:
9292
* https://discourse.julialang.org/t/ref-vs-zero-dimensional-arrays/24434
9393

src/ZeroDimensionalArrays.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module ZeroDimensionalArrays
33
export
44
ZeroDimArray,
55
Box,
6-
BoxConstField
6+
BoxConst
77

88
struct ZeroDimArray{T} <: AbstractArray{T, 0}
99
v::T
@@ -22,7 +22,7 @@ mutable struct Box{T} <: AbstractArray{T, 0}
2222
end
2323
end
2424

25-
mutable struct BoxConstField{T} <: AbstractArray{T, 0}
25+
mutable struct BoxConst{T} <: AbstractArray{T, 0}
2626
const v::T
2727
global function new_zero_dimensional_array_mutable_const_field(::Type{T}, v) where {T}
2828
new{T}(v)
@@ -32,15 +32,15 @@ end
3232
const ZeroDimensionalArray = Union{
3333
ZeroDimArray,
3434
Box,
35-
BoxConstField,
35+
BoxConst,
3636
}
3737

3838
function type_to_constructor_function(::Type{T}) where {T <: ZeroDimensionalArray}
3939
if T <: ZeroDimArray
4040
new_zero_dimensional_array_immutable
4141
elseif T <: Box
4242
new_zero_dimensional_array_mutable
43-
elseif T <: BoxConstField
43+
elseif T <: BoxConst
4444
new_zero_dimensional_array_mutable_const_field
4545
else
4646
throw(ArgumentError("no such constructor function"))
@@ -102,7 +102,7 @@ end
102102
for Arr (
103103
ZeroDimArray,
104104
Box,
105-
BoxConstField,
105+
BoxConst,
106106
)
107107
@eval begin
108108
function Base.convert(::Type{$Arr}, a::AbstractArray{<:Any, 0})

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using Aqua: Aqua
1111
for Arr (
1212
ZeroDimArray,
1313
Box,
14-
BoxConstField,
14+
BoxConst,
1515
)
1616
@test (@inferred Arr(0.3)) == (@inferred convert(Arr, fill(0.3)))
1717
@test isstructtype(Arr)
@@ -51,9 +51,9 @@ using Aqua: Aqua
5151
only(a) === 0.7
5252
end
5353
end
54-
@testset "`BoxConstField`" begin
55-
@test @isdefined BoxConstField
56-
@test ismutabletype(BoxConstField)
54+
@testset "`BoxConst`" begin
55+
@test @isdefined BoxConst
56+
@test ismutabletype(BoxConst)
5757
end
5858
end
5959
end

0 commit comments

Comments
 (0)