Open bronze1man opened 6 years ago
btw, what's about type alias, I mean
const Alias = fn () void;
pub fn registerHandler(al: Alias) void {
unreachable;
}
should it emit a compiler error in those case?
What about types in comptime closures?
pub fn Foo(comptime T: type) type {
const A = struct { ptr: *T }; // no way to access A from outside...
return struct {
val: T,
pub fn getPtr(self: *@This()) A {
return .{ .ptr = &self.val };
}
};
}
@Hadron67 It can easily be expressed with
pub fn Foo(comptime T: type) type {
return struct {
pub const A = struct { ptr: *T };
val: T,
pub fn getPtr(self: *@This()) A {
return .{ .ptr = &self.val };
}
};
}
Am I missing something ?
I have saw the part of the source code in the
std/io.zig
I think the return type is like
!std.io.File
so I write follow code:But it is not work:
So I have to change the code like this(it works):
So I have follow proposal:
This proposal will make reading code easier.