[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Src question
Quoting Matthew Flatt:
> For those who want a longer explanation:
>
> MzScheme "inlines" references of the elements of a vector in the base
> record (which contains the type tag and vector size), instead of
> allocating a separate array of references.
So does that mean that a vector assignment can potentially involve a
copy of the vector? Perhaps you "deinline" on an assignment sometimes?
So, does that mean that this implementation of build-vector:
;; build-vector : int (int -> X) -> (vectorof X)
;; purpose: to construct a vector of size i,
;; filled with tha values of (f j) for 0 <= j <= i-1
(define (build-vector i f)
(let ([v (make-vector i #f)])
... iterate, filling the vector ...
v))
is worse than this one:
;; build-vector : int (int -> X) -> (vectorof X)
;; purpose: to construct a vector of size i,
;; filled with tha values of (f j) for 0 <= j <= i-1
(define (build-vector i f)
(let ([lst (... create a list of the elemnts ...)])
(apply vector lst)))
?
Note: The MzLib collection actually contains the first, not the second.
Robby