cmsc430 / cmsc430.github.io

CMSC 430 Design and Implementation of Programming Languages
https://cmsc430.github.io/
45 stars 33 forks source link

Recursive printing is broken #152

Open pdarragh opened 11 months ago

pdarragh commented 11 months ago

When we have self-referential heap structures, the output loops infinitely and must be interrupted:

> (let ([v (make-vector 1 #t)]) (begin (vector-set! v 0 v) v))
#0='#(#0#)
> (run (compile (parse '(let ([v (make-vector 1 #t)]) (begin (vector-set! v 0 v) v)))))
^Cuser break [,bt for context]

It'd be nice to implement a (simple) check for these cases and indicate the recursion somehow.

laelath commented 11 months ago

It looks like Racket resolves these by printing out the recursive equations i.e. for this example it prints #0='#(#0#).