-
Notifications
You must be signed in to change notification settings - Fork 29
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
Enable getproperty
for Symbol
keys
#43
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
authors = ["Andy Ferris <[email protected]>"] | ||
name = "Dictionaries" | ||
uuid = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" | ||
version = "0.3.7" | ||
version = "0.3.8" | ||
|
||
[deps] | ||
Indexing = "313cdc1a-70c2-5d6a-ae34-0150d3930a38" | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -48,11 +48,11 @@ end | |||||||
|
||||||||
## getproperty is equivalent to indexing with a `Symbol` | ||||||||
|
||||||||
# @propagate_inbounds Base.getproperty(d::AbstractDictionary, s::Symbol) = d[s] | ||||||||
# @propagate_inbounds function Base.setproperty!(d::AbstractDictionary, s::Symbol, x) | ||||||||
# d[s] = x | ||||||||
# return x | ||||||||
# end | ||||||||
@propagate_inbounds Base.getproperty(d::AbstractDictionary, s::Symbol) = d[s] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strings and Ints also work: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One could probably restrict the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also Strings and Ints should work, as I commented half a year ago above :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So something like
Suggested change
|
||||||||
@propagate_inbounds function Base.setproperty!(d::AbstractDictionary, s::Symbol, x) | ||||||||
d[s] = x | ||||||||
return x | ||||||||
end | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also using ConstructionBase
ConstructionBase.setproperties(obj::AbstractDictionary, patch::NamedTuple) = merge(obj, Dictionary(keys(patch), values(patch))) would be nice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With Julia 1.9 it'll be a lot easier to include opt-in "weak" dependencies on other packages on the ecosystem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that was just a suggestion - ConstructionBase is so lightweight and widely used that I didn't even think it can/should be made a weakdep. |
||||||||
## Non-scalar indexing | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.