OCaml中的输出关键字
我想知道关键字OCaml中的输出关键字,ocaml,Ocaml,我想知道关键字output在OCaml中的含义 我看了一下文件,上面写着: val output : out_channel -> bytes -> int -> int -> unit output oc buf pos len writes len characters from byte sequence buf, starting at offset pos, to the given output channel oc. Raise Invalid_argum
output
在OCaml中的含义
我看了一下文件,上面写着:
val output : out_channel -> bytes -> int -> int -> unit
output oc buf pos len writes len characters from byte sequence buf, starting at offset pos, to the given output channel oc. Raise Invalid_argument "output" if pos and len do not designate a valid range of buf.
问题是我根本不明白这一切意味着什么
如果您能提供一个使用关键字输出的简单代码示例,那就太好了
谢谢大家! 没有关键字
输出
。pervisives
模块中只有一个名为output的函数
output
的目的是将一些字节写入输出通道
如果您选择可打印字节,并且如果您的输出通道是标准输出,您可以在一个小测试中看到结果:
# let mybytes = Bytes.of_string "hello\n";;
val mybytes : bytes = Bytes.of_string "hello\n"
# output stdout mybytes 0 6;;
hello
- : unit = ()
#
要显示output
只是一个标识符(即名称)而不是关键字,请注意,您可以定义自己的名为output
的值:
# let output = 3010;;
val output : int = 3010
#
对于真正的关键字,例如then
,情况并非如此:
# let then = 3010;;
Error: Syntax error
#
没有关键字
输出
。pervisives
模块中只有一个名为output的函数
output
的目的是将一些字节写入输出通道
如果您选择可打印字节,并且如果您的输出通道是标准输出,您可以在一个小测试中看到结果:
# let mybytes = Bytes.of_string "hello\n";;
val mybytes : bytes = Bytes.of_string "hello\n"
# output stdout mybytes 0 6;;
hello
- : unit = ()
#
要显示output
只是一个标识符(即名称)而不是关键字,请注意,您可以定义自己的名为output
的值:
# let output = 3010;;
val output : int = 3010
#
对于真正的关键字,例如then
,情况并非如此:
# let then = 3010;;
Error: Syntax error
#