<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 23, 2013, at 1:05 PM, Christopher wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: 'Lucida Grande'; 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; "><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-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 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-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 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><span class="Apple-converted-space"> </span>clause or later when I try to instantiate the class with<span class="Apple-converted-space"> </span><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></span></blockquote></div><div><br></div><div><br></div>init contract clauses are useful to check the initial value: <br><div><br></div><div><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> (init string-thing)</div><div> (super-new)))</div><div><br></div><div>(print (new my-string% (string-thing 10)))</div><div><br></div></div><div><br></div><div>As it turns out, the class initialization system is so dynamic in Racket that it is impossible to decide whether a class has an init parameter or an init-field. </div><div><br></div><div><br></div></body></html>