Re: Adding dot-notation in an ISO conforming manner
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 12/10/2013 05:13 AM, Richard A. O'Keefe wrote: > I seem to have missed something. > > Does this mean that if I do > write_canonical([a,b,c]) > in some other Prolog, getting > '.'(a, '.'(b, '.'(c, []))) > and then try to read this in SWI Prolog, > it will read as something *other* than [a,b,c]? > > Why is this thought to be a good idea? It is not. It is a consequence though and not too bad. First of all, SWI-Prolog can talk to itself and to other Prolog systems. It is just that SWI-Prolog cannot read the write_canonical/1 output of other systems. That is a pity of course. As a work around, there is an option dotlists(true) to read_term/3 and write_term/3 which causes these to pretend that lists are ./2 terms. For canonical exchange between Prolog systems, using the dotlists(true) option for reading should suffice. If you have non-Prolog readers you might have to abandon write_canonical/1 and use write_term/2 with dotlist(true), quoted(true) and ignore_ops(true). Or better, change the reader to understand the list syntax. That will probably fix handling long lists as well ... > Oh well, since [] reads as the wrong kind of data > structure anyway, it was already broken. > > But the *point* of write_canonical was to facilitate > data interchange between Prologs. > > Changing the list constructors from '[]' and '.' is > looking like a worse and worse idea. > > There isn't any problem with write_canonical reading > and writing strings, but getting list reading wrong > is, well, ... There is a much bigger problem if the data representation relies on strings not being lists. That problem would really upset exchange, while the above problem requires merely changing a flag. Cheers --- Jan