1

该程序在 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)

它是一个程序的骨架,它不断地从终端交互中读取数据,并对用户的输入和数据状态进行处理。

但是,在终端上,使用

raco exe prog.rkt

它在第一次输入后终止。有谁知道为什么?它是 read-line 还是 current-input-port 的错误/功能?

4

1 回答 1

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!

于 2016-02-05T15:35:54.053 回答