关于zig “.”点操作符的一些疑惑 #303
-
|
pub fn reader(file: File, buffer: []u8) Reader { return .init(file, buffer); } |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
.操作符是使用的对应类型的命名空间, 在这里即是 Reader.init()
文件即结构体, 结构体即命名空间; |
Beta Was this translation helpful? Give feedback.
-
|
https://ziglang.org/download/0.14.0/release-notes.html#Decl-Literals 这是 0.14 引入的语法,叫 decl literals,可以翻译成“声明字面量”,它能够根据上下文的环境自动推导出所属的作用域,官方叫:Result Location Semantics |
Beta Was this translation helpful? Give feedback.
https://ziglang.org/download/0.14.0/release-notes.html#Decl-Literals
这是 0.14 引入的语法,叫 decl literals,可以翻译成“声明字面量”,它能够根据上下文的环境自动推导出所属的作用域,官方叫:Result Location Semantics