lack of vector-copy in r4rs 
Author Message
 lack of vector-copy in r4rs

I was reading the r4rs Scheme standard this morning and was surprised to
discover that the expressions "hello" and '#(1 2 3) may denote immutable
constants.  So the following could (should?) generate errors:

        (define foo "hello")
        (define bar '#(1 2 3 4))

        (string-set!  foo 2 #\X)        ; expression 1, erroneous
        (vector-set! bar 2 100)         ; expression 2, erroneous

I haven't yet seen a Scheme interpreter generate an error for expression 1,
but one interpreter I use does generate an error for expresion 2.

Questions:

Why is there no vector-copy function?  If an implementation makes vector
constants immutable, it would seem handy to have vector-copy.  Was string-copy
provided for a different reason, one that does not also apply to vectors?



Tue, 21 Jul 1998 03:00:00 GMT  
 lack of vector-copy in r4rs


Quote:
>Why is there no vector-copy function?  If an implementation makes vector
>constants immutable, it would seem handy to have vector-copy.  Was string-copy
>provided for a different reason, one that does not also apply to vectors?

Perhaps because it's almost as easy to make mutable vectors as it is to
type vector constants:

(define bar (vector 1 2 3 4))

If the elements of the vector aren't self-evaluating, it's a little more
verbose:

(define bar (vector 'a 'b 'c 'd))

but not unwieldy.

String-copy was presumably included because programs that manipulate text
need to do this frequently (e.g. to make a copy of a line that you edit,
while saving the original).
--
Barry Margolin
BBN PlaNET Corporation, Cambridge, MA

Phone (617) 873-3126 - Fax (617) 873-6351



Tue, 21 Jul 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Text-only OR HTML copy of R4RS ??

2. no vector = vector*vector in BLAS?

3. Distributions and integrals, and old copies of VECTOR

4. copying a vector?

5. Problem with vector copy

6. copying vectors/arrays by value

7. Vector set!, void vector problem

8. matrix as vector of vectors

9. Inserting a vector slice into another vector

10. Optimal SSE code for dot producting 4 vectors with another vector for the Athlon

11. BLT vector creation: creation time grows as number of vectors created grows

12. (simple-vector 20) vs (vector single-float 20)

 

 
Powered by phpBB® Forum Software