[racket-dev] Catching the undefined value

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 16 09:08:39 EDT 2014

At Wed, 16 Apr 2014 09:02:44 -0400, Matthias Felleisen wrote:
> 
> On Apr 15, 2014, at 9:29 PM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:
> 
> > On 2014-04-15 18:13:31 -0400, claire alvis wrote:
> >> The push below includes changes to letrec expressions, internal
> >> definitions, units, classes, and certain ill-formed shared expressions so
> >> that they no longer leak the `undefined' value.
> > 
> > This is great! (especially happy that TR, even with classes, doesn't
> > have to worry about #<undefined> anymore)
> > 
> > BTW, I found this weird behavior:
> > 
> >  Welcome to Racket v6.0.1.3.
> >  -> (require racket/unsafe/ops)
> >  -> (let () (+ x 3) (define x 3) 5)
> >  ; x: variable used before its definition [,bt for context]
> >  -> (let () (unsafe-fx+ x 3) (define x 3) 5)
> >  5
> 
> 
> I consider this correct in a strange sense. 
> 
> Interestingly enough, 
> 
> > (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
> x: variable used before its definition
>   context...:
>    /Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7
> 
> which is good too. I don't know how Claire and Matthew did this, 
> but it's good :-) 

I've pushed a repair for Asumu's example.

The part of the optimizer that throws out unsafe operations with unused
results could be triggered before the letrec-fixing pass, and the
optimization wasn't as conservative as it needs to be at that point
about local variables.


Posted on the dev mailing list.