A random atom is not a dict
?- is_dict(atom,X). false.
A dict tagged "foo" is tagged "foo" indeed
?- is_dict(foo{},foo). true.
Extracting the tag of a dict
?- is_dict(foo{},X). X = foo.
An "anonymous dict" is a dict tagged as "foo" (this actually sets the tag of the anonymous dict to "foo" but we will never be able to ascertain this because there is no intruction to the right of the is_dict/2 call).
?- is_dict(_{},foo). true.
Making another variable to denote the "hole" of an "anonymous dict"
?- is_dict(Y{},X), X == Y. Y = X.
Setting/Binding/Refining the still fresh tag of the dict? Yes, we can. Generally, the value is an atom or a "small integer":
?- A=X{}, is_dict(A,X), X=foo. A = foo{}, X = foo.
Bizarre: Setting the tag to something that is not an atom or a small integer:
?- A=X{}, is_dict(A,k{}). A = k{}{}, X = k{}.
Actually you can unify the tag as you like:
?- A = X{a:1}, X = [1,2,3]. A = [1, 2, 3]{a:1}, X = [1, 2, 3].
Jan writes:
"You can indeed create dicts that have any tag. read/1 can only read dicts that have an atom or variable as tag. There is little that can be done against that. The only thing that is theoretically possible is to use an attributed variable instead of a plain variable. That seems a big overkill for a small mostly theoretical problem."