Reputation: 33375
I'm writing a program in Racket, which I'm running with racket foo.rkt
. This works, except that the result of every expression at the program top-level gets printed, even though no print function was called. It's as if the program were entered line by line to the REPL, but in this case I'm not trying to use the REPL at all, I'm just trying to run a program from the command line.
How do you get Racket to not print things?
Upvotes: 2
Views: 1411
Reputation: 48745
#lang racket
, the default language in the Racket implementation, prints top level statements except (void)
, that returns a value that is always ignored by the REPL, and (values)
, which return zero values back and thus REPL has nothing to print. This means you can make a main
function that ends with either one of them and it will have no output from the REPL.
statement-1
statement-2
statement-3
And change this to:
(define (main)
statement-1
statement-2
statement-3
(void)) ; or (values)
Forms like define
and set!
returns the same value as (void)
for th exact same purpose.
Not all languages supported by racket prints top level statements. The actual Scheme language #!r6rs
, does not print top level statements.
Upvotes: 5