Closed Shyam-Has-Your-Anomaly-Mitigated closed 2 years ago
There doesn't seem such a thing as a bug. There can't be as Prolog syntax is undefined for non-ASCII :smile: Anyway, резреирей is a sequence of digits and the syntax for an unquoted atom is letter [letter | digit or "_"]*
. A sequence of digits thus is not a valid atom. As being a letter or a digit is derived from the Unicode tables, this holds for any script.
Prolog only defines semantics for Latin digits, parsing 0123 to the integer 123 (it can not be distinguished from 123, i.e., 0123 == 123
succeeds. A sensible point of discussion could be what we should do with sequences of digits of other scripts (nor preceded by a letter because this turn them into an atom). I guess there are three options
резреирей == 123
--> true.резреирей == 'резреирей'
Might be better to discuss this on our Discourse forum
i traced the bug to atom_concat/3 treating numbers as atoms, but member/2 doesn't; so `numerals(['0','1','2','3','4','5','6','7','8','9']).` fixes my second bug, and i guess i'll just singley quote exotic numerals to fix my first bug, and maybe use macros to sugar the single quotes away (time to `dcg(prolog)`!!! :D); but i think atom_concat/3, and member/2, should agree, unless it's specified? where is your source? i imagine it's iso? i'll start datamining!
but i think atom_concat/3, and member/2, should agree
They do different things. atom_concat/3 defines the concatenation relation between three atoms. According to ISO, all arguments are variables or atoms. SWI-Prolog is a bit more relaxed, accepting also integers as input. The output arguments are always unified to atoms. This allows for e.g. atom_concat(a,42,X)
, which is quite useful. Member is based on unification and 1 = '1'
is never true in Prolog.
Notice that atom_concat(X,Y,0123)
gives X='', Y = '123'
as the 0 is lost in the translation to an integer.
Unfortunately macros won't help much as they manipulate terms (after the parser), so they cannot make anything legal syntax. They can only change the term.
Closing as this is not a bug. Quite likely some people on the forum are interested in these complicated script issues :smile:
This issue has been mentioned on SWI-Prolog. There might be relevant details there:
https://swi-prolog.discourse.group/t/unicode-symbols-and-a-possible-numerical-paradox/5533/1