f(.{}) is calling a function, which takes a struct, using an in-place constructor which provides the default arguments for the necessary struct type.
f({}) is passing an instance of `void` to a function with a `void` type parameter. Do you need to do this, specifically? No. But you can.
fn voidPass(v: void) void {
_ = v;
}
test "void pass" {
voidPass({});
}Adding an entry requires you to pass a void value:
map.put("hi", {});Standard C has no such feature as blocks being expressions.
Compound literals are grotesque. The braces have to be proceeded by cast syntax indicating the type. It could be subject to inference. Maybe the current draft has something.
Parentheses, brackets and braces I find can help a lot in guiding your eyes though code. They make it more „regular“, or lessen the „entropy“ (physicists, please don‘t stone me).
For this reason I‘ve come to dislike Rust’s braceless if-syntax, after being a die-hard fan. With parentheses it just reads better.
my_func((my_type){ .x = 1, .y = 2 });
my_func(&(my_type){ .x = 1, .y = 2 });Every single time, I am telling you, every single time I must write an anonymous struct using that dot, I am becoming totally confused!
Me too buddy, me too!
Edit: I should put an /s here, am I right?