Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Agreed. And p.* is remarkably unintuitive and nonsensical compared to *p.


It's remarkably intuitive and sensible if you remember that . in Zig auto-dereferences for field access and then treat `*` in this construct as field name denoting the entire object.

Ada does the same exact thing, except there you write `p.all` instead.

In any case, while the exact syntax may not be ideal, using a postfix operator for dereferencing is vastly better than prefix in practice due to typical patterns of use. There's a reason why you end up writing () a lot in C code with heavy pointer operations - the things they end up mixed with most often turn out to have the wrong kind of priority and/or precedence more often than not. Things are much simpler when everything is postfix and code reads naturally left-to-right.


It's not at all unintuitive of nonsensical. You're just really used to *p because it what C uses.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: