Skip to content

Commit f9217a7

Browse files
author
Andy Ferris
committed
Rename EnvHash to EnvDict
1 parent f092e8f commit f9217a7

File tree

8 files changed

+34
-29
lines changed

8 files changed

+34
-29
lines changed

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ Deprecated or removed
10421042
10431043
* `num` and `den` have been deprecated in favor of `numerator` and `denominator` respectively ([#19233],[#19246]).
10441044
1045-
* `delete!(ENV::EnvHash, k::AbstractString, def)` has been deprecated in favor of
1045+
* `delete!(ENV::EnvDict, k::AbstractString, def)` has been deprecated in favor of
10461046
`pop!(ENV, k, def)`. Be aware that `pop!` returns `k` or `def`, whereas `delete!`
10471047
returns `ENV` or `def` ([#18012]).
10481048
@@ -1187,6 +1187,8 @@ Deprecated or removed
11871187
* Parsing string dates from a `Dates.DateFormat` object has been deprecated as part of a
11881188
larger effort toward faster, more extensible date parsing ([#20952]).
11891189
1190+
* `EnvHash` has been renamed to `EnvDict` ([#24167]).
1191+
11901192
Command-line option changes
11911193
---------------------------
11921194

base/deprecated.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const _oldstyle_array_vcat_ = false
151151

152152
@deprecate write(x) write(STDOUT::IO, x)
153153

154-
function delete!(::EnvHash, k::AbstractString, def)
154+
function delete!(::EnvDict, k::AbstractString, def)
155155
depwarn("`delete!(ENV, k, def)` should be replaced with `pop!(ENV, k, def)`. Be aware that `pop!` returns `k` or `def`, while `delete!` returns `ENV` or `def`.", :delete!)
156156
haskey(ENV,k) ? delete!(ENV,k) : def
157157
end
@@ -1913,6 +1913,9 @@ end
19131913
@deprecate float(x::AbstractString) parse(Float64, x)
19141914
@deprecate float(a::AbstractArray{<:AbstractString}) parse.(Float64, a)
19151915

1916+
# issue #24167
1917+
@deprecate EnvHash EnvDict
1918+
19161919
# END 0.7 deprecations
19171920

19181921
# BEGIN 1.0 deprecations

base/env.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,42 +59,42 @@ end # os test
5959
## ENV: hash interface ##
6060

6161
"""
62-
EnvHash() -> EnvHash
62+
EnvDict() -> EnvDict
6363
6464
A singleton of this type provides a hash table interface to environment variables.
6565
"""
66-
struct EnvHash <: Associative{String,String}; end
66+
struct EnvDict <: Associative{String,String}; end
6767

6868
"""
6969
ENV
7070
71-
Reference to the singleton `EnvHash`, providing a dictionary interface to system environment
71+
Reference to the singleton `EnvDict`, providing a dictionary interface to system environment
7272
variables.
7373
"""
74-
const ENV = EnvHash()
74+
const ENV = EnvDict()
7575

76-
similar(::EnvHash) = Dict{String,String}()
76+
similar(::EnvDict) = Dict{String,String}()
7777

78-
getindex(::EnvHash, k::AbstractString) = access_env(k->throw(KeyError(k)), k)
79-
get(::EnvHash, k::AbstractString, def) = access_env(k->def, k)
80-
get(f::Callable, ::EnvHash, k::AbstractString) = access_env(k->f(), k)
81-
in(k::AbstractString, ::KeyIterator{EnvHash}) = _hasenv(k)
82-
pop!(::EnvHash, k::AbstractString) = (v = ENV[k]; _unsetenv(k); v)
83-
pop!(::EnvHash, k::AbstractString, def) = haskey(ENV,k) ? pop!(ENV,k) : def
84-
delete!(::EnvHash, k::AbstractString) = (_unsetenv(k); ENV)
85-
setindex!(::EnvHash, v, k::AbstractString) = _setenv(k,string(v))
86-
push!(::EnvHash, k::AbstractString, v) = setindex!(ENV, v, k)
78+
getindex(::EnvDict, k::AbstractString) = access_env(k->throw(KeyError(k)), k)
79+
get(::EnvDict, k::AbstractString, def) = access_env(k->def, k)
80+
get(f::Callable, ::EnvDict, k::AbstractString) = access_env(k->f(), k)
81+
in(k::AbstractString, ::KeyIterator{EnvDict}) = _hasenv(k)
82+
pop!(::EnvDict, k::AbstractString) = (v = ENV[k]; _unsetenv(k); v)
83+
pop!(::EnvDict, k::AbstractString, def) = haskey(ENV,k) ? pop!(ENV,k) : def
84+
delete!(::EnvDict, k::AbstractString) = (_unsetenv(k); ENV)
85+
setindex!(::EnvDict, v, k::AbstractString) = _setenv(k,string(v))
86+
push!(::EnvDict, k::AbstractString, v) = setindex!(ENV, v, k)
8787

8888
if Sys.iswindows()
89-
start(hash::EnvHash) = (pos = ccall(:GetEnvironmentStringsW,stdcall,Ptr{UInt16},()); (pos,pos))
90-
function done(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
89+
start(hash::EnvDict) = (pos = ccall(:GetEnvironmentStringsW,stdcall,Ptr{UInt16},()); (pos,pos))
90+
function done(hash::EnvDict, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
9191
if unsafe_load(block[1]) == 0
9292
ccall(:FreeEnvironmentStringsW, stdcall, Int32, (Ptr{UInt16},), block[2])
9393
return true
9494
end
9595
return false
9696
end
97-
function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
97+
function next(hash::EnvDict, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
9898
pos = block[1]
9999
blk = block[2]
100100
len = ccall(:wcslen, UInt, (Ptr{UInt16},), pos)
@@ -108,10 +108,10 @@ if Sys.iswindows()
108108
return (Pair{String,String}(m.captures[1], m.captures[2]), (pos+(len+1)*2, blk))
109109
end
110110
else # !windows
111-
start(::EnvHash) = 0
112-
done(::EnvHash, i) = (ccall(:jl_environ, Any, (Int32,), i) === nothing)
111+
start(::EnvDict) = 0
112+
done(::EnvDict, i) = (ccall(:jl_environ, Any, (Int32,), i) === nothing)
113113

114-
function next(::EnvHash, i)
114+
function next(::EnvDict, i)
115115
env = ccall(:jl_environ, Any, (Int32,), i)
116116
if env === nothing
117117
throw(BoundsError())
@@ -126,15 +126,15 @@ else # !windows
126126
end # os-test
127127

128128
#TODO: Make these more efficent
129-
function length(::EnvHash)
129+
function length(::EnvDict)
130130
i = 0
131131
for (k,v) in ENV
132132
i += 1
133133
end
134134
return i
135135
end
136136

137-
function show(io::IO, ::EnvHash)
137+
function show(io::IO, ::EnvDict)
138138
for (k,v) = ENV
139139
println(io, "$k=$v")
140140
end

contrib/Julia_Notepad++.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<Keywords name="Folders in comment, middle"></Keywords>
2626
<Keywords name="Folders in comment, close"></Keywords>
2727
<Keywords name="Keywords1">true false C_NULL Inf NaN Inf32 NaN32 nothing</Keywords>
28-
<Keywords name="Keywords2">AbstractArray AbstractMatrix AbstractRange AbstractRemoteRef AbstractSparseMatrix AbstractString AbstractVector Any ArgumentError Array Associative BigFloat BigInt BitArray BitMatrix BitVector Bool BunchKaufman Cchar Cdouble Cfloat Char CharString CholeskyDense CholeskyPivotedDense Cint Cintmax_t Clong Clonglong Colon Complex Complex128 Complex64 ComplexPair Cptrdiff_t Cshort Csize_t Cuchar Cuint Cuintmax_t Culong Culonglong Cushort DArray Dict Dims DisconnectException EOFError EachLine EnvHash ErrorException Exception Expr Factorization Filter Float Float32 Float64 Function GSVDDense IO IOBuffer IOStream ImaginaryUnit InsertionSort Int Int128 Int16 Int32 Int64 Int8 IntSet Integer KeyError LDLTTridiagonal LUDense LUTridiagonal LoadError LocalProcess Matrix MergeSort MethodError NTuple Number ObjectIdDict ObjectIdDict OrdinalRange ParseError PipeBuffer ProcessGroup Ptr QRDense QRPivotedDense QuickSort RangeIndex Rational Real Regex RegexMatch RegexMatchIterator RepString RevString Reverse SVDDense Set Signed SparseMatrixCSC SpawnNullStream Stat StridedArray StridedMatrix StridedVecOrMat StridedVector String SubArray SubDArray SubOrDArray SubString SymTridiagonal Symbol SystemError Task TCPSocket TimSort Tridiagonal Tuple Type TypeError UInt UInt128 UInt16 UInt32 UInt64 UInt8 UVError Union UnitRange Unsigned VecOrMat Vector VersionNumber Void WeakKeyDict WeakRef Zip</Keywords>
28+
<Keywords name="Keywords2">AbstractArray AbstractMatrix AbstractRange AbstractRemoteRef AbstractSparseMatrix AbstractString AbstractVector Any ArgumentError Array Associative BigFloat BigInt BitArray BitMatrix BitVector Bool BunchKaufman Cchar Cdouble Cfloat Char CharString CholeskyDense CholeskyPivotedDense Cint Cintmax_t Clong Clonglong Colon Complex Complex128 Complex64 ComplexPair Cptrdiff_t Cshort Csize_t Cuchar Cuint Cuintmax_t Culong Culonglong Cushort DArray Dict Dims DisconnectException EOFError EachLine EnvDict ErrorException Exception Expr Factorization Filter Float Float32 Float64 Function GSVDDense IO IOBuffer IOStream ImaginaryUnit InsertionSort Int Int128 Int16 Int32 Int64 Int8 IntSet Integer KeyError LDLTTridiagonal LUDense LUTridiagonal LoadError LocalProcess Matrix MergeSort MethodError NTuple Number ObjectIdDict ObjectIdDict OrdinalRange ParseError PipeBuffer ProcessGroup Ptr QRDense QRPivotedDense QuickSort RangeIndex Rational Real Regex RegexMatch RegexMatchIterator RepString RevString Reverse SVDDense Set Signed SparseMatrixCSC SpawnNullStream Stat StridedArray StridedMatrix StridedVecOrMat StridedVector String SubArray SubDArray SubOrDArray SubString SymTridiagonal Symbol SystemError Task TCPSocket TimSort Tridiagonal Tuple Type TypeError UInt UInt128 UInt16 UInt32 UInt64 UInt8 UVError Union UnitRange Unsigned VecOrMat Vector VersionNumber Void WeakKeyDict WeakRef Zip</Keywords>
2929
<Keywords name="Keywords3">abstract begin baremodule primitive break catch ccall const continue do else elseif end export finally for function global if struct import importall let local macro module quote return try mutable typealias using while</Keywords>
3030
<Keywords name="Keywords4">close enumerate error info open print println read write warn</Keywords>
3131
<Keywords name="Keywords5">print println</Keywords>

contrib/julia.lang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
<keyword>Eigen</keyword>
270270
<keyword>EmptyCallStack</keyword>
271271
<keyword>Enumerate</keyword>
272-
<keyword>EnvHash</keyword>
272+
<keyword>EnvDict</keyword>
273273
<keyword>Executable</keyword>
274274
<keyword>Expr(Node)?</keyword>
275275
<keyword>Factorization</keyword>

contrib/julia.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<item> EachLine </item>
109109
<item> Eigen </item>
110110
<item> Enumerate </item>
111-
<item> EnvHash </item>
111+
<item> EnvDict </item>
112112
<item> Exception </item>
113113
<item> Expr </item>
114114
<item> FileMonitor </item>

doc/src/stdlib/base.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Base.@timev
257257
Base.@timed
258258
Base.@elapsed
259259
Base.@allocated
260-
Base.EnvHash
260+
Base.EnvDict
261261
Base.ENV
262262
Base.Sys.isunix
263263
Base.Sys.isapple

doc/src/stdlib/collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Partially implemented by:
216216

217217
* [`IntSet`](@ref)
218218
* [`Set`](@ref)
219-
* [`EnvHash`](@ref Base.EnvHash)
219+
* [`EnvDict`](@ref Base.EnvDict)
220220
* [`Array`](@ref)
221221
* [`BitArray`](@ref)
222222

0 commit comments

Comments
 (0)