If you had one wish for zig, what would it be?

I want infer. Like this:

fn function(generic_param: infer T) ReturnType {
    ...
}

Instead of this:

fn function(comptime T: type, generic_param: T) ResultType {
    ...
}

Or this:

fn function(generic_param: anytype) ResultType {
    const T = @TypeOf(generic_param);
    ...
}

It has the potential for some amount of type matching, with arything that’s a structural type:

fn function(generic_ptr: *infer T) ResultType {
    ...
}

And also using result type location for userland functions:

fn function(arg: Arg) infer T {
    switch (@typeInfo(T)) {
        ...
    }
    ...
}
13 Likes