[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New text on Quotation

This page is part of the web mail archives of SRFI 116 from before July 7th, 2015. The new archives for SRFI 116 contain all messages, not just those from before July 7th, 2015.



Here's the new material I've added to the Quotation section:

The various Scheme standards permit, but do not require, Scheme
implementations to treat quoted pairs and lists as immutable.  Thus
whereas the expression (set-car! (list 1 2 3) 10) evaluates to the list
(10 2 3), the expression (set-car! '(1 2 3) 10) is not portable and in
fact an error.

This SRFI recommends that implementations that provide both this SRFI
and immutable quotations should cause quotations to return the same
immutable pairs that this SRFI describes.  This means that the standard
Scheme pair and list operations, as well as libraries like SRFI 1 which
are built on them, should accept both mutable and immutable pairs: thus
(car (ilist 1 2)) should evaluate to 1.

This SRFI further recommends that read should return mutable pairs and
lists when reading list structure.  No recommendation is made about the
behavior of write, display, and similar output procedures on immutable
lists.

To make life easier for Scheme programmers, given that many
implementations do not provide immutable quotation, the syntax keyword
iq is provided as part of this SRFI.  It is analogous to quote, taking
an arbitrary number of literals and constructing an ilist from them,
with any pairs in the literals converted to ipairs. It is useful for
providing constant ipair-based objects.  Note that pairs within literal
vectors or other implementation-dependent literals will not be converted.
Unfortunately, there is no ilist analogue of ', so we save keystrokes
by using iq rather than iquote and omitting the top-level parentheses.

I've put the latest version at <http://www.ccil.org/~cowan/temp/srfi-116.html>.
Comments?

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@xxxxxxxx
It was impossible to inveigle
Georg Wilhelm Friedrich Hegel
Into offering the slightest apology
For his Phenomenology.                      --W. H. Auden, from "People" (1953)