Pmt_dict API change in master

Changeset cbbe4816f99ac introduces an API change in the pmt library.

I doubt that this change will cause problems for anyone, but if does,
see below for the changes you’ll have to make to your code.

With the change, pmt_dict becomes an immutable object (“persistent” in
functional programming lingo), and is now safe to pass in messages.

The primary change is that the old key/value setter:

//! dict[key] = value
void pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value);

is replaced with:

//! Return a new dictionary with \p key associated with \p value.
pmt_t pmt_dict_add(const pmt_t &dict, const pmt_t &key, const pmt_t
&value);

It returns a new dictionary with the key, value association added.
The previous dictionary is unchanged.

There is also a new function that returns a version of a dictionary
with a key removed:

//! Return a new dictionary with \p key removed.
pmt_t pmt_dict_delete(const pmt_t &dict, const pmt_t &key);

The new implementation is simple-minded. If it gets to be a
performance problem, we can replace it with a persistent red-black
tree or something similar.

Eric

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs