I want to change how Racket prints some values both in REPL and when using 
(print), (println), e.t.c.

Suppose that I want change like this (gives as simple example):

(define (print~ datum [out (current-output-port)] [quote-depth 0])
  (if (number? datum)
      (print `',datum out 1)
      (print datum out quote-depth)))

So Racket will print all numbers with preceeding quote.
This definition is in separate file and is exported like this:

(provide (rename-out [print~ print]))

So in other files it is seen as (print) function.

Problems/questions:

1. Although it redefines (print), it does not affect (println) and other print 
functions.
Is there a way to re-define print and make Racket use it for other printing 
functions (because I suspect that their definitions are based on (print))?
Or I should redefine all printing functions?

2. When I try to make REPL use this function for printing I hook it like this:

(current-print (lambda (val)
                 (if (void? val)
                     (void)
                     (begin 
                       (print val)
                       (newline)))))

Here (print) is modifyed print from example imported with the name of standart 
function.

It seems to work, but it prints output to REPL in purple color, while by 
default it prints in the same colours as inputed values, so it easier to 
differentiate between REPL output and output generated by explicit use of 
(print).

Did I hook my custom print function wrong? Did I used wrong type of function? 
Is there a way to fix this?

-- 
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.

Reply via email to