> On Apr 7, 2019, at 9:54 PM, Raoul Schorer <raoul.scho...@gmail.com> wrote: > > Thanks, indeed it does work. > Although if I am not mistaken, I did not see mention of > (current-print) > > in "Beautiful Racket" or in the doc tutorial on writing languages. Do I have > a special case, or is it routinely used but not mentioned? Is it because I > did not provide a > #%top-interaction > > form for my language yet?
Every expression at the top level of a module is treated as if it had `current-print` wrapped around it. Therefore, in the `funstacker` tutorial in Beautiful Racket [1], it's not actually necessary to call `display`. Still, because I'm writing for people new to Racket, I think it's wiser to promote a habit of explicitly calling an output function. Why? Because as you move code around, you may be surprised when something stops printing (because it's no longer at the top level). For instance, new Racketeers might be confused as to why the output of this program: #lang racket 1 (begin 2 3) (let () 4 5) is this (4 is not printed): 1 2 3 5 Whereas it's more obvious that this program: #lang racket (displayln 1) (begin (displayln 2) (displayln 3)) (let () (displayln 4) (displayln 5)) Produces this: 1 2 3 4 5 Beyond that, I do very little with output in Beautiful Racket, so it's simpler to just use `display` for the few instances (instead of detouring to explain the nuances of `current-print` etc.) [1] https://beautifulracket.com/funstacker/source-listing.html <https://beautifulracket.com/funstacker/source-listing.html> -- 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.