<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>To paraphrase Sarah Silverman's comedy special, "Vectors are Magic."<br>
While cons cells can be allocated and initialized and chained together<br>
one at a time, vector memory must be (or should be) allocated as a block<br>
and then initialized in a nice tight loop.&nbsp; This creates some problems
for<br>
typed code.<br>
<br>
Case in point, I'm trying to implement SML's style enumerate array<br>
constructor in typed-scheme.<br>
<br>
The code is a little messy as I've been trying different things,<br>
but I think the essential errors&nbsp; are apparent.<br>
<br>
<big><b>(define: (x) (enumerate [size : Integer] [init : (Integer -&gt;
x)]) : (Vectorof x)<br>
&nbsp; (let: ([v : (Vectorof x) (make-vector size)]) ; &lt;&lt;&lt; big
problem<br>
&nbsp;&nbsp;&nbsp; (for ([k (in-range size)])&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;&lt;&lt; problem
#2 I can't seem to grok<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (vector-set! v k (init k)))))</b></big><br>
<br>
So the first obvious problem is that make-vector has no obvious<br>
default value of the type variable x.<br>
<br>
The second error is a little more obscure to me and relates to the for<br>
expression. <br>
<br>
Here is DrScheme's error message:<br>
<br>
<b><big><font color="#ff0000">typecheck: untyped identifier in-range
imported from module &lt;for.ss&gt; in: in-range<br>
typecheck: Expected (Vectorof x), but got Void in: fold-var</font></big></b><br>
<br>
Scott<br>
</tt>
</body>
</html>