From ok@atlas.otago.ac.nz Thu Feb  8 02:08:27 2001
Received: from atlas.otago.ac.nz (atlas.otago.ac.nz [139.80.32.250])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f1818PZ03266
	for <prolog@swi.psy.uva.nl>; Thu, 8 Feb 2001 02:08:26 +0100 (MET)
Received: (from ok@localhost)
	by atlas.otago.ac.nz (8.9.3/8.9.3) id OAA10272;
	Thu, 8 Feb 2001 14:08:16 +1300 (NZDT)
Date: Thu, 8 Feb 2001 14:08:16 +1300 (NZDT)
From: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
Message-Id: <200102080108.OAA10272@atlas.otago.ac.nz>
To: bouquard@univ-tours.fr, prolog@swi.psy.uva.nl
Subject: Re:  [SWIPL] element=singleton list

"Bouquard Jean-Louis" <bouquard@univ-tours.fr> asked:
	
	How do you explain the confusion between a number N
        and a list of a number [N]?

The same way that you explain the confusion between a number N and
the expression +N.

There is, in short, NO CONFUSION whatsoever.
Just as Fortran and Algol and PL/I and Pascal and C and most programming
languages have a unary + operator that does nothing, so Prolog has a
[ _ ] operator in expressions, that does nothing.

Recall that DEC-10 Prolog very sensibly defined a string to be a list of
character codes, so "A" is [65] and "Z" is [90].  In order to do arithmetic
on characters, as practical programs all must, somewhere, the definition
of arithmetic expressions says that a list of one character code IS NOT
but EVALUATES TO the numeric value of that character.

Thus

    is_ascii_upper_case_letter(C) :-
        "A" =< C, C =< "Z".

This proved a bit awkward, so in DEC-10 Prolog the notation was superseded
by radix 0.  Prolog integers can be expressed in non-decimal bases as
	<radix>'<extended digits>
e.g., 8'177, 16'FED.  Radix 0 is character codes, so one can write

    is_ascii_upper_case_letter(C) :-
        between(C, 0'A, 0'Z).

However, the old feature in arithmetic expressions was not removed;
unlike the ISO Prolog committee we didn't see any point in breaking
existing working code.

So the fact that [2] evaluates to 2 (IN AN ARITHMETIC EXPRESSION ONLY)
is no more surprising than the fact that +2 evaluates to 2, and a lot
more useful.

