In addition to its other uses, SWI-Prolog parses an unquoted comma as atom, leading to:
?- atom(,).
true.
?- (,,) =.. L.
ERROR: Syntax error: Unexpected `,' before `)'
ERROR: (,
ERROR: ** here **
ERROR: ,) =.. L .
?- (,,,) =.. L.
L = [',', ',', ','].
This appears to be due to the fact that ‘,
’ is defined as a solo character atom like ‘!
’ and ‘;
’. On researching a couple of other Prolog’s with formal syntax specifications (Eclipse and Sicstus), they only define ‘!
’ and ‘;
’ as solo-character atoms.
And I’m not sure this is still the case, but a draft of the ISO standard (Covington, 1994) also does not permit an unquoted ‘,
’ to be an atom.
So I think this is a unnecessary source of incompatibility and perhaps not the intent, as the following error message might suggest:
?- atom(|).
ERROR: Syntax error: Operand expected, unquoted comma or bar found
ERROR: atom
ERROR: ** here **
ERROR: (|) .
IMO, it would be better to treat an unquoted comma like an unquoted bar. (Note that this would not preclude its use as an operator in unquoted form, just like the bar.) Is there a reason for its current implementation?