You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of Racket are you using?
v8.5.0.8 [cs] on Linux x86_64
What program did you run?
(require racket/struct)
(struct a (b)
#:methods gen:custom-write
[(define (write-proc s port mode)
(print (struct->list s) port mode))])
(a 1)
struct->list by default raises an exception when given an opaque struct, which itself tries to write the struct instance, and the recursion begins. Keep an eye on your memory when that is happening.
What should have happened?
Maybe it is best to simply give users a warning in the documentation. Otherwise, perhaps this could be handled by detecting the recursion with a parameter somewhere in the custom-write or pretty.rkt code. After detection, another exception could be raised instead.
The text was updated successfully, but these errors were encountered:
I made an edit to the program examples for simplicity.
Normally I'd say that this recursion problem is the users' responsibility to address, but because it's kind of sneaky and error values are not always thoroughly documented, it seemed surprising and I thought I should post it.
This issue does not appear to be viewed as something to be addressed at the language level, so I'm closing it out of the way. Going forward, if I encounter similar scenarios I will first ask about them on Discourse to determine their worthiness as an issue.
I don't think this is a bad report. But I'm not sure if it can be fixed, how it can be fixed, and if it's a good idea to fix it.
A perfect fix is impossible, but perhaps give up after 5 or 10 recursive errors in the error report? Can that break something? Can it be annoying in some weird corner case? I'll not make any attempt to fix this, but it's one of those things that would be nice to keep in mind.
What version of Racket are you using?
v8.5.0.8 [cs] on Linux x86_64
What program did you run?
struct->list
by default raises an exception when given an opaque struct, which itself tries to write the struct instance, and the recursion begins. Keep an eye on your memory when that is happening.What should have happened?
Maybe it is best to simply give users a warning in the documentation. Otherwise, perhaps this could be handled by detecting the recursion with a parameter somewhere in the custom-write or
pretty.rkt
code. After detection, another exception could be raised instead.The text was updated successfully, but these errors were encountered: