I have found an uxpected type error.
?- arg(1, a, X).
ERROR: Type error: `compound' expected, found `a' (an atom)
ERROR:  arg(1,a,_102)
ERROR:  toplevel_call('<garbage_collected>') at /Users/cantor/lib/swipl/boot/toplevel.pl:1173
I expected it should be simply false because related queries on
=../2 suggested it should simply fail.
% ?- arg(2, a(1), X).
?- functor(T, a, 0).
T = a.
?- functor(T, a, 1).
T = a(_).
?- a =.. U.
U = [a].
?- a(1)=.. U.
U = [a, 1].
Perhaps I prefer to view atoms as a special case in which terms of arity is 0 as suggested by
=../2. I hope the query
arg(1, a, _) simply fails in the future version.
The syntax of SWI-Prolog is rather more complex that ISO Prolog. Did you considered
Basically, I interpret this feature as an attempt to better separate atomic terms - that get their semantic by metalanguage (i.e. builtins) - from compounds (except unification).
I don’t think there are many chances Jan will change the arg/3 behaviour… but you could wrap your own preferred behaviour by means of term rewriting, no ?
I am not sure I fully understand the meaning of f(). But it was useful for converting S-expressions in lisp and prolog terms. In particular, S-expression (a) to the swi-prolog term a(). Without the form a(), it was difficult to convert lisp atom a in to prolog term. That is, my understanding is that a() was the call form of predicate a without argument, though I am far from sure for the semantics of a().
As your suggestion, there is an easy workaoound for that type error. Thanks for comment.