Just made a funny observation. SWI-Prolog allows other things than
atom as a functor in a compound. For example it allows me to do:
/* atom as functor */
?- Y =.. [foo, bar].
Y = foo(bar).
/* stream as functor */
?- current_input(X), Y =.. [X, bar].
X = <stream>(0000000069066420),
Y = <stream>(0000000069066420)(bar).
I wonder whether there is a name for what is allowed as a functor,
i.e atom or stream etc.. . The error message by SWI-Prolog doesn't
tell me what is the name, it says it expects an atom:
?- Y =.. [1, bar].
ERROR: Type error: `atom' expected, found `1' (an integer)
But as can be seen a stream etc.. , which is accepted, is not an atom:
?- current_input(X), atom(X).
false.
What is the umbrella type for what SWI-Prolog accepts as functor?
P.S. My guess why this is allowed: It is for example used for Dicts,
dicts are compounds with a special functor C'dict'.
Edit 10.09.2021:
I first thought its simple/1. But simple/1 is reserved
for atom or var, according to this answer:
What is the meaning of predicate "simple/1" in Prolog (SWI-Prolog)
In SWI-Prolog, blobs (binary large objects) are used to store arbitrary binary data, including atoms, images, and stream handles. Particularly, a blob represening a stream handle is a unique symbol which has no syntactical representation (although it is outputted as <stream>(hex-number)
).
The built-in predicate blob/2
can be used to get the type of a blob:
?- X = foo, blob(X,Y).
X = foo,
Y = text.
?- current_input(X), blob(X,Y).
X = <stream>(0000000069057160),
Y = stream.
Thus, I think the type accepted as functor in SWI-Prolog is blob.