6 ms·
You forgot hash table and regular expression literals.
by shawn_w 25d ago
You forgot hash table and regular expression literals.
- GregBuchholz 25d agoIt looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs): '#0=(0 . #0#) ...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2))) (display |1 + 2|))
- soegaard 25d agoThat has been in Racket for a long time.
- GregBuchholz 25d agoI tried: #lang racket/base (let ((a '#0=(0 . #0#))) (display (car a))) ...over at https://onecompiler.com/racket https://onecompiler.com/racket ...and it didn't compile, complaining: read-syntax: `#...=` forms not enabled for `read-syntax` mode ...maybe there is a switch needed to enable it?
- soegaard 25d agoI am not 100% sure what's going on, but you can use `read` mode this way: #lang racket (let ((a (read (open-input-string "#0=(0 . #0#)")))) (display (car a))) I think the problem is that `read` / `write` support shared data constructed using `shared`. But programs (read by `read-syntax` are not allow to have cycles.
- shawn_w 25d agoYeah, there's a toggle for it in read-syntax mode. https://docs.racket-lang.org/reference/Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax-accept-graph%29%29 https://docs.racket-lang.org/reference/Reading.html#%28def._...
- GregBuchholz 25d agoHow do you get that to work? #lang racket (read-syntax-accept-graph #t) (let ((a '#0=(0 . #0#))) (display (car a))) ...which of course doesn't work, because `(read-syntax-accept-graph)` is a run-time thing, and the circular-list structure is a `read`-time thing. I couldn't figure it out with this either: https://stackoverflow.com/questions/51942188/read-syntax-forms-not-enabled https://stackoverflow.com/questions/51942188/read-syntax-for... ...just to make sure I wasn't going crazy, this: (let ((a '#0=(0 . #0#))) (display (car a))) ...does work as expected with this online scheme interpreter: https://www.jdoodle.com/execute-scheme-online https://www.jdoodle.com/execute-scheme-online
- shawn_w 25d agoIt might take a custom #lang. I'll play around with it when I have some free time... That read-syntax doesn't just accept everything accepted by plain read is one of my biggest annoyances with Racket.
- shawn_w 25d agoIt's ugly and probably fragile and prone to break, but I found a way. Added it as an answer on that Stack Overflow question: https://stackoverflow.com/a/79997503/9952196 https://stackoverflow.com/a/79997503/9952196