Hi all!
The proposal for dictionaries (based mostly on SWI’s dictionaries other proposals for records, like Ciao’s argnames) introduce the syntax tag{k1:v1, ..., kn:vn}
. It still needs to be decided if this is a new class of terms/data or just syntactic sugar for terms. The second option would have less impedance.
One idea is that whenever a tag{k1:v1,... kn:vn}
term is read, keys are automatically reordered so that two dictionaries with same keys unify, no matter in which order they appeared.
It still needs to be decided if implementations should chose their own mapping to terms or if this mapping is fixed, as well as how does the internal representation interacts with predicates like arg/3
or functor/3
.
But before going forward, I’ve a question regarding the _{...}
syntax for dictionaries in SWI-Prolog. Allowing variables in the tag position would make impossible to use some internal representations like those merging tags and keys in the same functor.
A question, specially for Jan, is: what would be the uses for _{...}
? It helps matching against a dictionary with known tag, but AFAIK the keys must be known before hand (_{a:_} = _{b:_}
would fail) so the usage seems limited in my opinion. I’m not arguing that _{...}
should be not be allowed, but I think that the PIP would say that it is not mandatory, or that it depends on the implementation.
Any opinions? (Thanks!)