ImmutableDict documentation

After stumbling through using an ImmutableDict, I’d like to submit some documentation for the type. Is there a procedure for this?

1 Like

Hi,
the current official documentation is visible at

(or with ? ImmutableDict in REPL)
If you hover over the bottom right you get a link to its source code

So in order to improve that you have to fork the Julia repository, improve the code in that file and open a pull request to the Julia repo.

Usually it is good to have a bit of a discussion maybe even before you start working. What would you like to improve?

Thanks. Here’s what I wrote after my stumbling. What do you think?

ImmutableDict is a dictionary implemented as an immutable linked
list. It’s intended for small mappings with a few entries, a short
list of keywords perhaps; when the overhead of accessing a hash table is
higher than that of a linear search of a linked list. Because it’s an
unusual type, ImmutableDict is public rather than export; to
access it one must write Base.ImmutableDict

To create an ImmutableDict use

imdict = Base.ImmutableDict(key=>value, key=>value, ...)

This will put the first elements in the list and also define the type
of the list elements; the returned value will be the head of the
list. To add to the list use

imdict = Base.ImmutableDict(imdict, key=>value, key=>value, ...)

Pairs cannot be removed from the list, but they can be shadowed by
adding an additional pair with a duplicate key; indexing operations
will find the the last key added.

The types of elements may be specified; this is useful when keys or
values of Union or Any types are desired.

imdict = Base.ImmutableDict{Symbol,Any}(key=>value, key=>value,
...)

An empty ImmutableDict can be created by specifying the type and
giving no pairs; the type must be specified.

imdict = Base.ImmutableDict{Symbol,Any}()
1 Like

There have been no further comments, one like from someone who seems to be a respected member of the community. I’m going away, but when I get back, I think I’ll submit this.

2 Likes

Yeah, sure, submit it :slight_smile:

I would maybe leave out the parts where you interpret or the “it is intended for” part. That is maybe too verbose prosaic for a documentation.
Similarly the explanation on public/export – just mention what it is without explanation.

It sounds like you had difficulty using the data structure based on the current docs - if so, make sure to mention that, and to specify that the docs you have written are based on your experience as a docs reader and user.

1 Like