@pernia @matrix @MercurialBlack >is "sneed" the first argument because the function is defined that way in the struct, or because you called chuck() but called it as sneed.chuck()
We're getting to levels I am not comfortable answering with my knowledge but I think it's because sneed is an instance of the struct (if I did Sneed.chuck then the struct acts like a namespace). And if the definition inside the struct wouldn't match it, I'd get a compile error. But maybe I'm wrong here
RE: metaprogramming
Yeah, somewhat like C's macros but it's all basically in the same language as "normal Zig" and can call other zig functions and yeah. But yes you don't have to edit the compiler to do it
fn Foo(comptime T: type) type {
return struct {
pub fn bar(x: T) T { ... }
};
}
var something: Foo(f64) ...
This is one example of how you can do generic types, the "function" Foo gets executed in compile time and it basically returns a new structure/namespace soo you can just use Foo(typename) as a type now.
You can also do all kinds of weirder stuff like procedurally create a new struct with @Type() builtin and whatnot but that'd be pretty ugly and I bet that API changes every release