Hiya,
I often run into situations where I'd like to pass only the first comptime argument of a function. I want to know if there's an terse way to do this in function scope. I have a minimal example.
pub fn distanceFrom(self: Vec3, other: Vec3) f64 {
// v I wish that was more concise
const powf = struct {
fn powf(a: f64, b: f64) f64 {
return std.math.pow(f64, a, b);
}
}.powf;
const sqrt = std.math.sqrt;
const out = sqrt(
powf(other.x - self.x, 2) +
powf(other.y - self.y, 2) +
powf(other.z - self.z, 2)
);
return out;
}
Here I would like to assign the std.math.pow function to powf with the first argument passed as f64. The only way I can think of doing it here involves a shim function and a temporary struct. A single line like const powf = std.math.pow(f64) would be desirable, but I've checked and that's a syntax error. This is a minimal example, this desire comes up quite often when I am using generic types from the standard library.
Is anything like this possible?