I wrote a custom printer, and the printer itself has side-effects. As such, I need to be absolutely certain that when I print something, the print function only gets called once.
When checking my test cases, things were failing, and then I found out that Racket calls the print function multiple times to check for sharing. How can I turn this off? I am certain it's not necessary for what I'm printing. The racket documentation states "To avoid a recursive print (i.e., to print without regard to sharing with a value currently being printed), print instead to a string or pipe and transfer the result to the target port using write-string or write-special." Following the advice here, I changed my print procedure to look like this ;Prints a record (define (rec-print rec port mode) (define string-port (open-output-string)) (write-string (record-to-string rec) string-port) (write-string (get-output-string string-port) port)) where record-to-string is a function I have that converts a record into a string (without ever calling print or display or any of that) I imagined this would fix my problem, but it did not. The only way I have found to fix my problem is to check if the name of the port is "null" and if so, to not print to it. This is, however, hacky and I'd like something better if possible. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.