<!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. 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 are apparent.<br>
<br>
<big><b>(define: (x) (enumerate [size : Integer] [init : (Integer ->
x)]) : (Vectorof x)<br>
(let: ([v : (Vectorof x) (make-vector size)]) ; <<< big
problem<br>
(for ([k (in-range size)]) <<< problem
#2 I can't seem to grok<br>
(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 <for.ss> in: in-range<br>
typecheck: Expected (Vectorof x), but got Void in: fold-var</font></big></b><br>
<br>
Scott<br>
</tt>
</body>
</html>