我真的找不到那些提到这个的信息.这些标准的io描述符默认是在Lua中设置为缓冲还是非缓冲?如果需要,我可以从一种模式切换到另一种模式吗?
例如,在python中它提供了sys.stdin.detach使其无缓冲的功能.
见setvbuf.它是底层C setvbuf函数的接口.
例如,您可以像这样使用它:
io.stdout:setvbuf 'no' -- switch off buffering for stdout
Run Code Online (Sandbox Code Playgroud)
AFAIK Lua依赖于底层C运行时挂钩到标准流,因此我认为C标准流的通常保证适用.