Skip to content

goretkin/NamedNamedTuples.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NamedNamedTuples

Stable Dev Dev Build Status Build Status Coverage Coverage Coverage

In julia, NamedTuples are sort of like anonymous structs. Both NamedTuples structs have fields which are ordered, named, and typed. A "named NamedTuple" is therefore like a "named anonymous struct", which is kind of like a struct! Writing a method for NamedTuple, unless the function makes sense generically across all NamedTuples is probably a bad idea. This package gives a way to wrap the NamedTuple in a type so that you can dispatch on that type instead.

I have found this particularly useful until timholy/Revise.jl#18 is closed.

Even if you know all the field of your type from the get-go, you might still be interested in NamedNamedTuples if you're dealing with values that only have entries for some of the fields of the type. Instead of using nothing to indicate a "missing" value, you can just leave it out of the named tuple. Perhaps this is an alternative to what Rich Hickey calls "place-oriented programming (PLOP)". See the slide "Optionality and aggregates".

I was not aware of the ProtoStructs.jl package with the same purpose.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages