[comp.lang.prolog] list syntax

micha@ecrcvax.UUCP (Micha Meier) (10/05/87)

In article <2278@mulga.oz> lee@mulga.UUCP (Lee Naish) writes:
>
>	H.T is more readable
>	H.T says the functor is '.' and there are two arguments, H and T
>	H.T is one less character
>	H.T doesn't use 'funny' characters used for letters in Europe
>	H.T is not a syntactic special case (well,.. less so)
>
I definitely agree that the dot notation is more readable for pairs, however
if we adopt it, what is 1.2? If it is a pair, how do we write the real number?
If it is the real, the pair has to be written like '.'(1, 2) which is not
very nice, either. In any case the parser has to care much more what
to do with the dot (pair, real number, fullstop, part of another identifier,
solve conflicts like 1.2.3) so it IS a special syntactic case.

  As far as lists are concerned, I find [1, 2, 3] more readable than 1.2.3.[];
when teaching how this all works it is useful to see the nil at the end,
however when writing programs, the nil is just an end-marker and I prefer
not to see it at all.
  Another disadvantage of the dor notation is that H.T is an operator
and one has to care about its precedence.  When I see [a++b, c++d]
I know what it means, whereas a++b.c++d.[] needs the parentheses.

  For the use with functor/3 and =../2 the pair has to have a functor
and in many systems it is the dot so that when it is declared as an operator,
the dot notation works, which is a sort of compromise for those who want
to use it. Why it isn't defined in BSI what the functor of a pair is?

--Micha

cdsm@doc.ic.ac.uk (Chris Moss) (10/08/87)

In article <438@ecrcvax.UUCP> micha@ecrcvax.UUCP (Micha Meier) writes:
> Why it isn't defined in BSI what the functor of a pair is?

But it is! See production 7 in the March 1987 draft on pages 4,5
It appears as '.'@[Term|Rest] which being decoded means the term whose
functor is '.' and arguments are [Term|Rest].
Chris.