[r6rs-discuss] [Formal] Vector size in the read syntax

From: Aubrey Jaffer <agj>
Date: Mon Oct 16 23:02:22 2006

 | Date: Mon, 16 Oct 2006 13:13:59 +0200
 | From: =?ISO-8859-1?Q?Jens_Axel_S=F8gaard?= <jensaxel_at_soegaard.net>
 |
 | Submitter: Jens Axel S?gaard
 | Email address: jensaxel_at_soegaard.net
 | Issue type: Enchancement
 | Priority: Minor
 | Component: Lexical Syntax
 | Report version: 5.91
 | Summary: Vector size in read syntax
 |
 |
 | PROPOSAL
 | --------
 |
 | In section "3.3.2 Vectors" the read syntax of vector
 | datums are
 |
 | #(<datum> ...) .
 |
 | I propose to allow the following syntax:
 |
 | #<natural number>(<datum> ...)
 |
 | The natural number between the # and the opening parenthesis
 | denotes the vector size.
 |
 | If there are fewer <datum>s than the given size, the vector
 | is filled with the value denoted by the last <datum>.
 | E.g #4(0 1) denotes #(0 1 1 1).
 |
 | If no datums are present the vector is filled with 0.
 | E.g. #4() denotes #(0 0 0 0).
 |
 | More more <datum>s than the given size is not allowed.
 |
 |
 | RATIONALE
 | ---------
 |
 | The #<number>(<datum> ...) requires less memory to parse.
 |
 | During the parsing of, say, #100000(1 2 ...), the reader
 | can allocate the vector after seeing the #100000( and then
 | fill in the vector slots.
 |
 | With the #(1 2 ...) syntax the reader needs to allocate a
 | temporary data structure to hold the data, until all datums
 | have been read. Then the vector can be allocated and the
 | slots be filled.

What problem does this solve?

It can't be used in a Scheme program to initialize mutable vectors
because literal constants are not mutable.

As for reading in external data, it is rare that the tail of a vector
being read will have a run of identical values.

The Rationale would apply just as well to strings as it does to
vectors. Literal string constants are more common in programs than
literal vector constants.

(define foo '3#((a b)))

Is (eq? (vector-ref foo 1) (vector-ref foo 2)) ?

If so, then it is not the same as '#((a b) (a b) (a b)).
Received on Mon Oct 16 2006 - 23:01:49 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC