为什么我不能向 REPL 中的当前输出端口写入一个字节?
Why can't I write a byte to the current-output-port in the REPL?
当我在 REPL 中计算它时,为什么 (write-u8 49 current-output-port)
失败并出现错误?
赤壁计划 0.10.0:
> (write-u8 49 current-output-port)
ERROR in "write-u8": invalid type, expected Output-Port: #<opcode "current-output-port">
诡计 3.0.8:
scheme@(guile-user)> (import (scheme base))
scheme@(guile-user)> (write-u8 49 current-output-port)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure put-u8: Wrong type argument in position 1 (expecting open output port): #<<parameter> 7f38972eb9c0 proc: #<procedure 7f38972f4200 at ice-9/boot-9.scm:1361:3 () | (x)>>
麻省理工学院方案 11.2:
1 ]=> (write-u8 49 current-output-port)
;The object #[compiled-closure 12 ("dynamic" #xd) #x17c #x27f522c ...], passed as an argument to #[compiled-procedure 13 ("binary-port" #x3) #x1c #x291d984], is not the correct type
current-output-port
是一个程序。您必须调用它并将其 return 值用作 write-u8
.
的参数
(write-u8 49 (current-output-port))
当我在 REPL 中计算它时,为什么 (write-u8 49 current-output-port)
失败并出现错误?
赤壁计划 0.10.0:
> (write-u8 49 current-output-port)
ERROR in "write-u8": invalid type, expected Output-Port: #<opcode "current-output-port">
诡计 3.0.8:
scheme@(guile-user)> (import (scheme base))
scheme@(guile-user)> (write-u8 49 current-output-port)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure put-u8: Wrong type argument in position 1 (expecting open output port): #<<parameter> 7f38972eb9c0 proc: #<procedure 7f38972f4200 at ice-9/boot-9.scm:1361:3 () | (x)>>
麻省理工学院方案 11.2:
1 ]=> (write-u8 49 current-output-port)
;The object #[compiled-closure 12 ("dynamic" #xd) #x17c #x27f522c ...], passed as an argument to #[compiled-procedure 13 ("binary-port" #x3) #x1c #x291d984], is not the correct type
current-output-port
是一个程序。您必须调用它并将其 return 值用作 write-u8
.
(write-u8 49 (current-output-port))