|
3 | 3 | module ScopedValues
|
4 | 4 |
|
5 | 5 | export ScopedValue, with, @with
|
6 |
| -public get |
7 | 6 |
|
8 | 7 | """
|
9 | 8 | ScopedValue(x)
|
@@ -57,7 +56,7 @@ Base.eltype(::ScopedValue{T}) where {T} = T
|
57 | 56 |
|
58 | 57 | Test whether a `ScopedValue` has an assigned value.
|
59 | 58 |
|
60 |
| -See also: [`ScopedValues.with`](@ref), [`ScopedValues.@with`](@ref), [`ScopedValues.get`](@ref). |
| 59 | +See also: [`ScopedValues.with`](@ref), [`ScopedValues.@with`](@ref), [`get`](@ref). |
61 | 60 |
|
62 | 61 | # Examples
|
63 | 62 | ```jldoctest
|
@@ -141,24 +140,24 @@ julia> using Base.ScopedValues
|
141 | 140 |
|
142 | 141 | julia> a = ScopedValue(42); b = ScopedValue{Int}();
|
143 | 142 |
|
144 |
| -julia> ScopedValues.get(a) |
| 143 | +julia> get(a) |
145 | 144 | Some(42)
|
146 | 145 |
|
147 |
| -julia> isnothing(ScopedValues.get(b)) |
| 146 | +julia> isnothing(get(b)) |
148 | 147 | true
|
149 | 148 | ```
|
150 | 149 | """
|
151 |
| -function get(val::ScopedValue{T}) where {T} |
| 150 | +function Base.get(val::ScopedValue{T}) where {T} |
152 | 151 | scope = Core.current_scope()::Union{Scope, Nothing}
|
153 | 152 | if scope === nothing
|
154 | 153 | val.has_default && return Some{T}(val.default)
|
155 | 154 | return nothing
|
156 | 155 | end
|
157 | 156 | scope = scope::Scope
|
158 | 157 | if val.has_default
|
159 |
| - return Some{T}(Base.get(scope.values, val, val.default)::T) |
| 158 | + return Some{T}(get(scope.values, val, val.default)::T) |
160 | 159 | else
|
161 |
| - v = Base.get(scope.values, val, novalue) |
| 160 | + v = get(scope.values, val, novalue) |
162 | 161 | v === novalue || return Some{T}(v::T)
|
163 | 162 | end
|
164 | 163 | return nothing
|
@@ -191,7 +190,7 @@ new dynamic scope with `var` set to `val`. `val` will be converted to type `T`.
|
191 | 190 | `@with var=>val expr` is equivalent to `with(var=>val) do expr end`, but `@with`
|
192 | 191 | avoids creating a closure.
|
193 | 192 |
|
194 |
| -See also: [`ScopedValues.with`](@ref), [`ScopedValues.ScopedValue`](@ref), [`ScopedValues.get`](@ref). |
| 193 | +See also: [`ScopedValues.with`](@ref), [`ScopedValues.ScopedValue`](@ref), [`get`](@ref). |
195 | 194 |
|
196 | 195 | # Examples
|
197 | 196 | ```jldoctest
|
|
231 | 230 | Execute `f` in a new dynamic scope with `var` set to `val`. `val` will be converted
|
232 | 231 | to type `T`.
|
233 | 232 |
|
234 |
| -See also: [`ScopedValues.@with`](@ref), [`ScopedValues.ScopedValue`](@ref), [`ScopedValues.get`](@ref). |
| 233 | +See also: [`ScopedValues.@with`](@ref), [`ScopedValues.ScopedValue`](@ref), [`get`](@ref). |
235 | 234 |
|
236 | 235 | # Examples
|
237 | 236 | ```jldoctest
|
|
0 commit comments