<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Racketeers,</div><div><br></div><div>If I were 100% sure this was a bug, I might pass this on to the Racket developer list or some other collective with responsibility for correcting errant behavior, but being a new Racket user, I could easily just be ignorant of how the syntactic handlers involved are supposed to work.</div><div><br></div><div>Therefore, I pose to you these brief snippets of code with Racket's response and ask if you can help me determine whether it is doing what it is supposed to, and, if so, then what the Racket reasoning is for giving it this particular behavior.</div><div><br></div><div>So, this gives an error as expected:</div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><br></div><div><span style="font-family: Courier; ">#lang racket</span></div></blockquote></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><font face="Courier"><div><br></div><div>(define/contract my-string%</div><div> (class/c (field [string-thing string?]))</div><div> (class object%</div><div> (super-new)))</div><div><br></div><div>(print (new my-string%))</div><div><br></div></font></blockquote><span style="font-family: Courier; ">[running the code produces the following:]</span><br><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><font face="Courier"><div><br></div><div><div><div>Welcome to DrRacket, version 5.3.4 [3m].</div><div>Language: racket; memory limit: 128 MB.</div><div>. . ../../Applications/Racket v5.3.4/collects/racket/contract/private/blame.rkt:132:0: my-string%: broke its contract</div><div> no public field string-thing</div><div> in: (class/c (field (string-thing string?)))</div><div> contract from: (definition my-string%)</div><div> blaming: (definition my-string%)</div><div> at: unsaved-editor24875:3.17</div><div>> </div></div></div><div><br></div></font></blockquote>I declared a field in the class contract that was not defined in the actual class. I would want Racket to complain about this, and it does.<div><br></div><div>However, this does NOT work as expected (changed class/c keyword from "field" to "init"):<div><font face="Courier"><br></font></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font face="Courier"><div>#lang racket</div><div><br></div><div>(define/contract my-string%</div><div> (class/c (init [string-thing string?]))</div><div> (class object%</div><div> (super-new)))</div><div><br></div><div>(print (new my-string%))</div><div><br></div></font></div></blockquote><span style="font-family: Courier; ">[running the code produces the following:]</span><br><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><font face="Courier"><div><br></div><div><div>Welcome to DrRacket, version 5.3.4 [3m].</div><div>Language: racket; memory limit: 128 MB.</div></div><div><div>(object:my-string% ...)</div><div>> </div></div><div><br></div></font></blockquote>In other words, when I declare an initialization parameter in the class contract which is absent from the class declaration and is not inherited, I expect a contract violation exception to be raised, similar to the one above for the non-existant field, either on execution of the <i style="text-decoration: underline; ">define/contract</i> clause or later when I try to instantiate the class with <u style="font-style: italic; ">new.</u> However, Racket does not complain at all---at neither location.</div><div><br></div><div>If Racket does not check that init parameters declared in class/c are actually present in the class itself or one of its superclasses, why does the class/c form allow them to be declared at all? Is it just for documentation?</div><div><br></div><div>I appreciate the feedback. Thanks!</div><div><br></div><div>---Christopher</div></body></html>