[plt-scheme] 'unspecified' arguemnt of make-vector

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Wed Feb 23 04:55:08 EST 2005

Zhu Chongkai wrote:

> R5RS says:
> 
> procedure: (make-vector k)
> procedure: (make-vector k fill)
> 
> Returns a newly allocated vector of k elements. If a second argument is given, 
 > then each element is initialized to fill. Otherwise the initial contents of each
 > element is unspecified.

>>(make-vector 1 (if #f #f))
> #(#<void>)
> 
>>(make-vector 3)
> #(0 0 0)

> Should PLT-Scheme use (void) instead of 0 in the 'unspecified' case?
> Or could anyone tell why 0 is better?

First, R5RS doesn't specify what to fill in thus filling with zeros follows
the specification.

Second, the specification of MzScheme states that the filler should be
zeros

<http://download.plt-scheme.org/doc/209/html/mzscheme/mzscheme-Z-H-3.html#node_sec_3.7>.

An PLT using other routines than from the srfi would be very surprised
if the normal behaviour of make-vector suddenly changed.

The rationale behind using zero as filler is probably that
most people use vectors of zeros more often than vectors of the invisble
value.

-- 
Jens Axel Søgaard





Posted on the users mailing list.