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/08/2013 07:19 PM, Ulrich Neumerkel wrote:
>
> I have added this:
>
> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/SWI7_and_ISO#adding_conforming_dot

It is an interesting thought.  I don't really understand the example.
Looks like a typo, as doing op(400,xfy,.) turns ON (I assume) the
special meaning of the . and the query should fail, no?

?- op(400,xfy,.).  % That is: turn off special meaning of .
true.
?- A.B = [1,2].
A = 1,
B = [2].

I'd expect this:

?- op(400,xfy,.).
?- writeq(A.B).
'$dot'(A,B)

Compatibility wise, this seems a step ahead.  Consistency wise, it
creates a difficult story.  .(A,B) \== A.B is weird at best.

The most nasty real problem this would solve is that read/write terms
using `canonical syntax' is currently broken. SWI7 reads/writes lists as
[H|T], unless the option dotlists(true) is given to read_term/3 or
write_term/3.

In itself, I already consider this a step in the right direction instead
of the wrong one.  Reading deeply nested terms in canonical syntax is
pretty hard without running out of stack because after reading f(, you
can do little else but reading arguments and pushing them onto a stack
until you see ) which allows you to count the pushed arguments and
create an f/N term.  Just try something to the equivalent of this in
various Prolog systems with an increasing list length:

1 ?- numlist(1, 10000, L),
      tell('x.pl'), write_canonical(l(L)), writeln(.), told.
2 ?- [x].

Using list notation for write canonical

   - Makes it way simpler to avoid this because you know [...] creates
     terms with arity 2.
   - Makes it way easier to write simple parsers/generators in other
     languages (one of the aims of the canonical syntax).
   - Does not introduce any ambiguity
   - Is easier to read by us, humans.

Considering the very minimal compatibility implications in using another
functor for lists, I'm inclined to keep it that way.  I will probably
change to '[|]' though.  It is already in Mercury and it would also have
been Joachim's choice.

	Cheers --- Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.