[plt-scheme] What is '(1 . 2 . 3)

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Nov 16 09:12:18 EST 2006

Akhilesh Mritunjai skrev:
> Hi
> 
> DrScheme 350 on Windows XP SP2 (and iirc, Solaris too)
> 
>> '(1 . 2 . 3)
> (2 1 3)
> 
>> (quote (1 . 2 . 3)
> (2 1 3)
> 
> on #scheme (freenode), people were of opinion that it is a bug (I too
> think so). Chez doesn't accept it.

Search the HelpDesk for "." (without the ""):

* A parenthesized sequence containing two delimited dots (``.'')
   triggers infix parsing. A single datum must appear between the dots,
   and one or more datums must appear before the first dot and after the
   last dot:

   (left-datum ···1 . first-datum . right-datum ···1)

   The resulting list consists of the datum between the dots, followed by
   the remaining datums in order:

   (first-datum left-datum ···1 right-datum ···1)

   Consequently, the input expression (1 . < . 2) produces #t, and
   (1 2 . + . 3 4 5) produces 15.

To the double dot notation is for infix. It works will for contracts
like  (string? integer? . -> . boolean? ).


If you want to disable the double dot notation, use the read-accept-dot
parameter:

* When the read-accept-dot parameter is set to #f, then a delimited dot
   (``.'') is disallowed in input. When the read-accept-quasiquote
   parameter is set to #f, then a backquote or comma is disallowed in
   input. These modes simplify Scheme's input model for students.


About #scheme: Please enlighten them about the double dot notation.
Note that with the exception of elibarilay, none (I know) of the
#schemers is on this list. That is, for PLT questions ask here first.



-- 
Jens Axel Søgaard



Posted on the users mailing list.