clarifying that field names are symbols William D Clinger 21 Jun 2016 13:49 UTC

The following clarification repairs an omission that has begun
to create some confusion.

SRFI 99's syntactic layer should be interpreted as though the
following sentence, taken from R6RS Libraries section 6.2, were
present within its specification:

    The <field name>s become, as symbols, the names of the
    fields in the record-type descriptor being created, in the
    same order.

The rest of this message explains what's at stake by relating
some history and giving some examples.

In specifications such as SRFI 99, the word "identifier" is
ambiguous.  As noted by R6RS section 4.2.4 and R7RS (small)
section 2.1, an identifier can mean any of these things:

  * the <identifier> nonterminal of the context-free grammar in
    R6RS section 4.2.1 and R7RS (small) section 7.1.1
  * the symbol denoted by an identifier within contexts that call
    for a syntactic datum
  * the denotation of an identifer within contexts that call for
    a variable or syntactic keyword

The specification of SRFI 99's syntactic layer says field names
are identifiers.  When the specification says field names are
identifiers, the word "identifier" is being used in the first
two senses above, as in the discussion of field names in R6RS
Libraries section 6.2.

If field names were interpreted in the third sense listed above,
inheritance of record fields would become unreliable.  Consider
the following program:

(define-library (foo)
  (export foo make-foo foo? foo.x foo.y)
  (import (scheme base))

  (begin

   (define x 1) ; x is an identifier denoting a location that holds the value 1
   (define y 2) ; y is an identifier denoting a location that holds the value 2

   (define-record-type foo
     (make-foo x y)
     foo?
     (x foo.x)
     (y foo.y))

   ;; Example:

   (define f (make-foo x y))

   ))

(define-library (bar)
  (export bar make-bar bar? bar.z)
  (import (scheme base)
          (scheme write)
          (srfi 99)
          (foo))

  (begin

   (define t 8)
   (define x 9)   ; this x denotes a different location from the x in foo
   (define y 10)  ; this y denotes a different location from the y in foo
   (define z 11)

   (define-record-type (bar foo)
     (make-bar t x y z)
     bar?
     (t bar.t)
     (z bar.z))

   ;; Example:

   (define b (make-bar t x y z))

   (write (list (bar.t b) (foo.x b) (foo.y b) (bar.z b)))
   (newline)

   ))

(import (bar))

That programs works if field names are symbols, as clarified by
this post-finalization message.  If field names were interpreted
in the third sense, as variable/keyword denotations, the program
above would not work because the identifiers x and y do not have
the same variable/keyword denotations in libraries (foo) and
(bar).

The program above works when run in Larceny or in Chibi or with
the the reference implementation of SRFI 99, which means Larceny
and Chibi have implemented the intended semantics in which field
names are interpreted symbols.

Will