<div dir="ltr"><div>Asumu, <br><br></div>Not sure I follow. If one uses a typed function imported into untyped Racket all bets are off.<br><br>(module foo typed/racket<br> (provide double)<br> (: double (Integer -> Integer))<br>
(define (double x)<br> (+ x x)))<br><br>(module bar racket<br> (require 'foo)<br> (double "2"))<br><br>(require 'bar) ;; fails<br><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, May 6, 2013 at 10:27 AM, Asumu Takikawa <span dir="ltr"><<a href="mailto:asumu@ccs.neu.edu" target="_blank">asumu@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 2013-05-06 10:09:06 -0400, Ray Racine wrote:<br>
> The below is now failing for me.<br>
> (struct: Stuff ([this : String][that : Natural]) #:prefab)<br>
><br>
</div>> [...]<br>
<div class="im">><br>
> If there is a typing issue with the use of #:prefab and its banishment<br>
> permanent, is there an alternate best practice mechanism for easy struct:<br>
> serialization/de-serialization?<br>
<br>
</div>If you're using the Racket pre-release, then that was probably my commit<br>
that broke that. Sorry for breaking compatibility here, but it's unsound<br>
for TR to admit #:prefab as is. Here's an example:<br>
<br>
$ racket<br>
Welcome to Racket v5.3.<br>
-> (module foo typed/racket<br>
(struct: foo ([f : (Float -> Float)]) #:prefab)<br>
(define x (foo (lambda: ([x : Float]) (* 3.3 x))))<br>
(provide x))<br>
-> (module bar racket<br>
(require 'foo)<br>
(struct foo (f) #:prefab)<br>
((foo-f x) "foo"))<br>
-> (require 'bar)<br>
2.293305645053357e-309<br>
<br>
The first module exports a #:prefab struct instance containing an<br>
optimized (Float -> Float) function. Since it's a prefab, the second<br>
module (which is untyped), can freely access the function stored inside.<br>
<br>
Since the function is unprotected, it does an unsafe multiplication on a<br>
string and no contract error is raised.<br>
<br>
I'm not sure what's a good alternative for serialization in TR off the<br>
top of my head.<br>
<br>
Cheers,<br>
Asumu<br>
</blockquote></div><br></div>