1

This program works fine in DrRacket :

(define (display-state input data)
  input)

(define (update-state input data) 
  data  )

(define (main input data)  
    (displayln (display-state input data))
    (main (read-line (current-input-port) 'any) (update-state input data)))

(main "" data)

It's the skeleton of a program that reads continually from a terminal interaction and does something with the user's input and a data state.

However, on the terminal, using

raco exe prog.rkt

It terminates after the first input. Anyone know why? Is it a bug / feature of read-line or current-input-port ?

interstar
  • 26,048
  • 36
  • 112
  • 180

1 Answers1

1

OK. I see what I did wrong. (Stupid, but I'll leave this in case anyone else has the same problem)

I expected raco exe to be running the program. But actually it was just compiling it into the executable.

So I was just typing into what I thought was the input when actually I was typing into the window waiting for compilation to terminate.

Actually I needed to compile with

raco exe prog.rkt

and THEN run with

./prog

Doh!

interstar
  • 26,048
  • 36
  • 112
  • 180
  • 1
    Normally I run Racket programs using `racket`. If you `raco make` (directly or via `raco setup`), that generates `compiled/*` bytecode files. That's the slowest part. Thereafter `racket` has "nothing" to do and is quite fast. JIT from bytecode to native code is very fast, and happens at runtime regardless. In other words `raco exe` is about deploying, making an executable to run on other computers. It's not the normal way people run locally. – Greg Hendershott Feb 05 '16 at 16:20
  • Actually, @GregHendershott I'm looking into Racket precisely because I want a Lisp for writing small, stand-alone command-line tools which don't need the full environment installed. – interstar Feb 05 '16 at 20:47