Why does SWI-Prolog unify a quoted and unquoted string (without spaces) to the same rule?

While atoms in SWI-PROLOG can be denoted using single quotes, e. G This is an atom single quotes are not needed when the SWI-PROLOG parser can identify an atom from a sequence of characters, usually starting with a lowercase alphabetic character, such as test If the sequence contained whitespace (or some other characters), you'd need the single quotes to denote an atom properly. Alphanumeric characters and certain punctuation characters like underscore are fine, e.

G test5_6.

While atoms in SWI-PROLOG can be denoted using single quotes, e. G, 'This is an atom', single quotes are not needed when the SWI-PROLOG parser can identify an atom from a sequence of characters, usually starting with a lowercase alphabetic character, such as test. If the sequence contained whitespace (or some other characters), you'd need the single quotes to denote an atom properly.

Alphanumeric characters and certain punctuation characters like underscore _ are fine, e.g. , test5_6. If the character sequence without single quotes were to start with anything else, such as a number 6k, the parser will treat it as a number; if it were an uppercase alphabetic character such as Test, the parser will treat it as a variable.

– Vivin Paliath Nov 4 '10 at 20:37 @Vivin Paliath: Perhaps, at least with SWI-PROLOG, though it seems typical of other PROLOG implementations I have seen as well. But nevertheless, yes, it is something the SWI-PROLOG parser will do in particular, perhaps if only to save you from having to single-quote all your atoms :-) – sharky Nov 4 '10 at 20:42 Thanks :) – Vivin Paliath Nov 4 '10 at 20:45.

This is not SWI specific behavior - it is required by the standard. There is a simple way to see this. You can use this also for any other term whose syntax is not evident.

Either type at the toplevel:? - X = 'test'. X = test.?- X = 'this is a test'.

X = 'this is a test'. The answer is always valid Prolog text - this is specific to SWI but also to many other Prolog systems. Another way to see this is to use write_canonical/1:?

- write_canonical('this is a test'). 'this is a test' true.?- write_canonical(a,b,(c,d),{e,f}). '.

'(a,'.'(b,'. '(','(c,d),'. '({}(','(e,f)),)))).

Very informative. Thanks! – Vivin Paliath Nov 5 '10 at 16:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions