Skip to content
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

define merge(combine, ::NamedTuple, ...) #36048

Open
goretkin opened this issue May 27, 2020 · 4 comments · May be fixed by #36291 or #53558
Open

define merge(combine, ::NamedTuple, ...) #36048

goretkin opened this issue May 27, 2020 · 4 comments · May be fixed by #36291 or #53558

Comments

@goretkin
Copy link
Contributor

julia> merge(+, Dict(:a=>3,:b=>5), Dict(:a=>4, :c=>6))
Dict{Symbol,Int64} with 3 entries:
  :a => 7
  :b => 5
  :c => 6

julia> merge(+, (a=3,b=5), (a=4,c=6))
ERROR: MethodError: no method matching merge(::typeof(+), ::NamedTuple{(:a, :b),Tuple{Int64,Int64}}, ::NamedTuple{(:a, :c),Tuple{Int64,Int64}})

As far as I can tell, this is simply an omission. Is there a reason to not define this?

@goretkin
Copy link
Contributor Author

I just noticed that these relevant changes: #34296

@tkf
Copy link
Member

tkf commented Jun 14, 2020

Yes, we should implement mergewith(combine, ::NamedTuple, ...) instead of merge(combine::Function, ::NamedTuple, ...).

@cossio
Copy link
Contributor

cossio commented Jun 14, 2020

Why mergewith? Given that merge does just this for Dict, why not use the same name for NamedTuple?

@tkf tkf linked a pull request Jun 15, 2020 that will close this issue
@tkf
Copy link
Member

tkf commented Jun 15, 2020

@cossio mergewith and mergewith! for dictionaries are added in Julia 1.5.

@aplavin aplavin linked a pull request Mar 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants