首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么不能将字节写入REPL中的当前输出端口?

为什么不能将字节写入REPL中的当前输出端口?
EN

Stack Overflow用户
提问于 2022-05-28 16:19:13
回答 1查看 52关注 0票数 0

当我在REPL中计算错误时,为什么(write-u8 49 current-output-port)会失败呢?

chibi-方案0.10.0:

代码语言:javascript
复制
> (write-u8 49 current-output-port)
ERROR in "write-u8": invalid type, expected Output-Port: #<opcode "current-output-port">

Guile 3.0.8:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-28 18:19:54

current-output-port是一种程序。您必须调用它并使用它的返回值作为write-u8的参数。

代码语言:javascript
复制
(write-u8 49 (current-output-port))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72417304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档