<div dir="ltr">Could Andrew Myer's work on masked types (to eliminate nulls for object initialization) be relevant?<div><a href="http://www.cs.cornell.edu/Projects/jmask/">http://www.cs.cornell.edu/Projects/jmask/</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 29, 2014 at 3:30 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@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"><br>
I guess the real problem is to create suitable default values so<br>
that the pass the type checker or to figure out a cast that forces<br>
TR to accept some other value as the default value (and making sure<br>
you never use the object).<br>
<br>
Undefined not completely solved. Argh. -- Matthias<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<br>
On Sep 29, 2014, at 12:52 PM, Sam Tobin-Hochstadt <<a href="mailto:samth@cs.indiana.edu">samth@cs.indiana.edu</a>> wrote:<br>
<br>
> Ah, if you want to create truly cyclic structure with no base case<br>
> like this, then you'll have to do more work. Either you'll need to<br>
> expand the type of the `x` field in `foo` to allow an initial value,<br>
> or you'll need to create a dummy `foo` with that extended type, and<br>
> then copy the cyclic data once you've created it to a new version of<br>
> `foo`, using hash tables to track cycles. That's basically how<br>
> `shared` works, although I haven't tried implementing it in TR and it<br>
> might not be possible.<br>
><br>
> Sam<br>
><br>
> On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen<br>
> <<a href="mailto:konrad.hinsen@fastmail.net">konrad.hinsen@fastmail.net</a>> wrote:<br>
>> Sam Tobin-Hochstadt writes:<br>
>><br>
>>> I recommend doing the mutation yourself, and not using `shared`.<br>
>>> That's the most obvious solution.<br>
>><br>
>> Not for me, unfortunately, but probably I am missing something<br>
>> obvious.<br>
>><br>
>> Here's explicit mutation in untyped Racket:<br>
>><br>
>>   #lang racket<br>
>><br>
>>   (struct foo (x) #:mutable)<br>
>>   (struct bar (x))<br>
>><br>
>>   (define f (foo (void)))<br>
>>   (define b (bar f))<br>
>>   (set-foo-x! f b)<br>
>><br>
>>   (eq? (bar-x b) f)<br>
>>   (eq? (foo-x f) b)<br>
>><br>
>> That works fine. Moving to Typed Racket, this is rejected by the type<br>
>> checker because (void) is of type Void.  Since I need a bar to make a<br>
>> foo and a foo to make a bar, I don't see how I can ever initialize my<br>
>> foo structure.<br>
>><br>
>>> The reason that your `require/typed` doesn't work is that it creates<br>
>>> new versions of the placeholder functions, but those aren't the ones<br>
>>> that `shared` uses internally, so Typed Racket doesn't use the types<br>
>>> you've given.<br>
>><br>
>> That makes sense, thanks for the explanation!<br>
>><br>
>> Konrad.<br>
> ____________________<br>
>  Racket Users list:<br>
>  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
<br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div>