Functor/3 for ,/2 - Printed result does not look right

Using SWI-Prolog (threaded, 64 bits, version 8.5.0-49-g2f46def0c) on Windows.

For functor/3, trying to use with functor of ,.

?- functor(T,',',2).
T =  (_, _).

was expecting something like

T =  ','(_, _).

EDIT

It seems to be more of printing issue than a conversion issue,
e.g. this conversation works as expected but does not print the term T as expected.

?- functor(T,',',2),functor(T,Funcotr,Arity).
T =  (_, _),
Funcotr =  (','),
Arity = 2.

This also works as expected.

?- functor(','(_,_),Functor,Arity).
Functor =  (','),
Arity = 2.

If you print T in canonical form (without any operators), the result is what you expect. (format ~k is write_canonical/1)

?- functor(T, ',', 2), format(string(Canonical), '~k', [T]).
T =  (_, _),
Canonical = "','(_,_)".
1 Like