<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 13, 2014, at 2:51 PM, Sam Tobin-Hochstadt wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><blockquote type="cite">(for/sum: : Flonum [[ii : Index 300]]<br></blockquote><blockquote type="cite">  pi)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">and I get the type error "Expected Flonum, but got Zero".  Where is there a<br></blockquote><blockquote type="cite">zero anywhere in this code?  And even if there were a zero, shouldn't Zero<br></blockquote><blockquote type="cite">be a subtype of Flonum?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Don't tell me the Zero I'm running into is the initial value of for/sum's<br></blockquote><blockquote type="cite">hidden accumulator....<br></blockquote><br>Unfortunately, that's exactly what I'm going to tell you.  Typed<br>Racket isn't smart enough to know that the initial value is never<br>used, and so 0 is thought to be a possibility.<br></div></blockquote><div><br></div><div>Doesn't that make for/sum: useless for anything other than exact integers?</div><div><br></div>Couldn't for/sum: initialize its accumulator to a Real-Zero rather than the overly-specified type Zero?  (That would rule out complexes, but it would be a big step in the right direction.)  (Should there be a Complex-Zero type?)</div><div><br></div><div>Even better, could for/sum: look at the annotation type and decide what initial value (0 or #i0.0) to use?</div><div><br></div><div><blockquote type="cite"><div>I recommend using `for/fold` for this case as a workaround.<br></div></blockquote></div><br><div>OK, I'll try that.</div><br><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Stephen Bloch</div><div><a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a></div></div></span>GPG  key at <a href="http://adelphi.edu/sbloch/sbloch.pubkey.asc">http://adelphi.edu/sbloch/sbloch.pubkey.asc</a></span>
</div>
<br></body></html>