Replies: 6 comments 1 reply
-
|
没吧,这个就是zig的基础语法吧 |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
如果不想混淆就显式传入类型,这种连点的写法实际上是让编译器自动推导类型 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
按Zig的结果位置语义来讲的话,我觉得这是个很好的设计,这个点就相当于跟在此处结果位置类型后一样 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
是非不分呀,这明明是漂亮的语法。C++也有类似语法,如 而以下这种情况必须要有这种语法才能实现: fn counterLabelUi(contex: *Contex) struct {
comptime widget: [:0]const u8 = "label",
x: i32 = 300,
y: i32 = 10,
w: i32 = 150,
h: i32 = 64,
text: [:0]const u8 = "Count",
on_init: struct {
ctx: *Contex,
pub fn init(self: @This(), widget: *zawtk.Widget) void {
self.ctx.label = widget;
}
},
} {
return .{ .on_init = .{ .ctx = contex } };
}
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
类比 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
参考下面这段伪代码:
大家不觉得这一行里面的 n 个
.号看起来很丑陋吗:Beta Was this translation helpful? Give feedback.
All reactions