99 points by todsacerdoti 2 days ago | 93 comments
karmakaze 13 hours ago
If the author's content is all in this 'assume no C background' style, it will be useful to those without previous manual memory management background in contrast to most articles that assume a lot of context.
klodolph 16 hours ago
skissane 13 hours ago
The thing I really wish C had, and which there is no straightforward workaround for, is postfix casting. When you do `((struct foo*)(COMPLEX_EXPRESSION))->field`, I think it would read a lot better if the `(struct foo*)` cast was on the same side as `->field`. Maybe something like `(COMPLEX_EXPRESSION)@(struct foo*)->field`
lostdog 12 hours ago
some_pointer*.field
skissane 11 hours ago
spacechild1 4 hours ago
fc417fc802 10 hours ago
It seems like `.` could in theory be made to recursively dereference any number of layers down to the base type. It's not as though `.` has any other possible meaning when used directly against an address ... right?
skissane 10 hours ago
https://retrocomputing.stackexchange.com/questions/10812/why...
pjmlp 7 hours ago
Yes, I know, comptime and such.
int_19h 4 hours ago
What this actually reminds me of is Ada, where you write `value.all` to basically the same effect as Zig's `value.*`. It's as if everything is a struct with itself as a member.
loxodrome 17 hours ago
xg15 5 hours ago
I think what seems weird though is more the "... = .{...}" syntax.
This makes it look as if there was some kind of anonymous object ".{...}" in memory that you're copying from, but there isn't. It's actually just a writing operation and the .{...} itself doesn't represent anything.
Maybe that was also what the author found confusing?