Formal comment #59 (enhancement) Vector size in the read syntax Reported by: Jens Axel Søgaard Component: lexicalsyntax Version: 5.91 Proposal In section "3.3.2 Vectors" the read syntax of vector datums are #( ...) . I propose to allow the following syntax: #( ...) The natural number between the # and the opening parenthesis denotes the vector size. If there are fewer s than the given size, the vector is filled with the value denoted by the last . 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 s than the given size is not allowed. Rationale The #( ...) 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. Current Practice Chez Scheme Vectors may be printed with an explicit length prefix, and when the explicit length prefix is specified, duplicate trailing elements may be omitted. For example, #(a b c) may be printed as #3(a b c), and a vector of length 100 containing all zeros may be printed as #100(0). The printer generally prints the prefix and suppresses duplicate trailing elements unless the parameter print-vector-length is set to false. PLT Scheme Vector constants can be unquoted, and a vector size can be specified with a decimal integer between the # and opening parenthesis. If the specified size is larger than the number of vector elements that are provided, the last specified element is used to fill the remaining vector slots. For example, #4(1 2) is equivalent to #(1 2 2 2). If no vector elements are specified, the vector is filled with 0. If a vector size is provided and it is smaller than the number of elements provided, the exn:fail:read exception is raised. SISC SISC supports the length prefix method of creating Vector constants. For example, '#5(x) creates a vector constant containing five identical symbols. In addition, the length-prefix form is used when printing vectors, and if elements repeat at the end of a Vector, only the last unique element is printed. This form is referred to as the compact vector representation. The unprefixed form with all elements displayed is called the verbose representation. Common Lisp RESPONSE: To expand on current practice: '#4(0 1 2 3) '#4(0 1) Bigloo 2.7a error error Petite Chez 7.0a #4(0 1 2 3) #4(0 1 1 1) Chicken 2,5 error error Gambit-C v4.0b20 error error Kawa 1.8 #(0 1 2 3) #(0 1) Larceny v0.93 error error MIT Scheme 7.7.90.+ error error MzScheme v352 #4(0 1 2 3) #4(0 1 1 1) Scheme 48 v1.3 error error SCM 5e1 error error Two of the three systems that allow the proposed syntax also use it (by default) when writing vectors, which has been a barrier to portability. There are two obvious ways to fix this non-portability: require the implementations that are using the syntax to stop using it (as was done by the current draft), or require all implementations to support it (as the comment proposes). The editors have decided that the proposed extension is not so important and so widely implemented that it should be required of all R6RS-conformant systems. The editors have therefore voted not to allow the proposed syntax.