<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>There’s a bug report about this here:</div><div><a href="http://bugs.racket-lang.org/query/?cmd=view&pr=14524">http://bugs.racket-lang.org/query/?cmd=view&pr=14524</a></div><div>Though I notice it gives a different error message now.</div><div>But why should structure type declarations being a module-wide construct?</div><div>Internal function definitions work, and internal type definitions work, so why shouldn’t internal structure definitions?</div><div><br></div><div><br></div><div><div>On Jan 22, 2015, at 3:57 PM, Alexis King <<a href="mailto:lexi.lambda@gmail.com">lexi.lambda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Simple enough. This works:<div class=""><br class=""></div><div class=""><div class=""><font face="Courier" class="">#lang racket</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">(define (make-me-a-struct)</font></div><div class=""><font face="Courier" class="">  (struct foo ())</font></div><div class=""><font face="Courier" class="">  (foo))</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">(make-me-a-struct) ; => #<foo></font></div></div><div class=""><br class=""></div><div class="">This does not:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier" class="">#lang typed/racket</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">(define (make-me-a-struct)</font></div><div class=""><font face="Courier" class="">  (struct foo ())</font></div><div class=""><font face="Courier" class="">  (foo)) ; error: cannot apply a function with unknown arity</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">(make-me-a-struct)</font></div></div><div class=""><br class=""></div><div class="">This problem makes sense. Type declarations seem to be a module-wide construct, so a type that should be scoped to a single function doesn’t work. I’m running into this issue when trying to create an executable struct using <font face="Courier" class="">define-struct/exec</font> from within a macro, which doesn’t work due to this particular problem.</div><div class=""><br class=""></div><div class="">I can work around this in a variety of ways—I can extract this into an untyped module and use <font face="Courier" class="">require/typed</font>, I can use vectors to “fake” structs and provide an appropriate interface, etc. Still, I wonder if there are any plans to resolve this type of problem? Since it seems to be an issue with how TR handles types at its core, I’m not even sure how feasible it would be.</div></div>_________________________<br>  Racket Developers list:<br>  <a href="http://lists.racket-lang.org/dev">http://lists.racket-lang.org/dev</a><br></blockquote></div><br></body></html>