-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ScopedValues.get
a method of Base.get
#54553
Comments
Ah, silly me, getindex(::ScopedValue) is already defined, yes. Did we consider making |
Maybe this line: Line 149 in baca8ba
Should be changed to this instead? - function get(val::ScopedValue{T}) where {T}
+ function Base.get(val::ScopedValue{T}) where {T} |
Ah Lilith beat me to it. |
|
ScopedValues.get
to Base.getindex
ScopedValues.get
a method of Base.get
We can do this after 1.11 in a nonbreaking way. From triage: it's complicated, let's talk about it later. In the future we could define this and merge the functions mutable struct Secret end
const SECRET = Secret()
function Base.get(x, index)
res = get(x, index, SECRET)
res === SECRET ? nothing : Some(res)
end |
|
I think if |
ScopedValues.get(::ScopedValues.ScopedValue)
performs a very similar role asBase.get(collection, index, default)
and I think they should have the same API and name, i.e. renameScopedValues.get
toBase.get
and make its API conform to the Baseget
API.Right now,
ScopedValues.get
is it's own generic function, distinct fromBase.getindex
and fromBase.get
.ScopedValues was introduced in 1.11, so this needs to be done before the 1.11 release if we want to do it at all.
Reading #50958, I don't see any explicit discussion about this name, but perhaps I'm missing something.
cc @vchuravy
The text was updated successfully, but these errors were encountered: