I'm currently learning the language, and I was wondering about this design quirk.
Basically, if we have a variable x which is a pointer, we use x.* to get the value. This is much better than using * as a prefix, since the * might need to be applied to anything in the chain for complex access. I see the usecase.
For example something like
(*(*pointer_to_struct).struct_field_ptr).struct_field
is much more clearly written as
pointer_to_struct.*.struct_field_ptr.*.struct_field
But then it feels really inconsistent that we don't do the same for taking a reference with &. Sure, we only ever take one reference of the entire value, so we don't have the same problem as above, but:
We still have the issue that the & is not next to the value being dereferenced:
&some_ptr.*.some_array_struct_field[5].target
this takes the address of the target struct field, which is on the opposite side of the expression.
It also just feels inconsistent.
Additionally, I think the type declaration for a pointer should be &u8, not *u8. Since the & character is semantically equivalent to "address of", and * is more like "value at address".
Thoughts?
btw it's clear to me that a .* can be omitted when accessing a struct field, but the operation is still there, it's just implicit.
Zig 0.16.0 Release Notes
2mon 3d ago by mander.xyz/u/nemeski in zig@programming.dev from ziglang.orgError Handling Guide — try, catch, errdefer
3mon 29d ago by lemmy.world/u/monica_b1998 in zig@programming.dev from slicker.meLessons from Zig
4mon 6d ago by programming.dev/u/codeinabox in zig@programming.dev from www.vinniefalco.comToday participating at the Zig Day event in Nuremberg: https://zig.day/europe/nuremberg/
4mon 10d ago by mastodon.social/users/sourcefranke in zig@programming.devZig and the M×N Supply Chain Problem
4mon 19d ago by programming.dev/u/codeinabox in zig@programming.dev from nesbitt.ioI Made Zig Compute 33 Million Satellite Positions in 3 Seconds. No GPU Required
4mon 27d ago by programming.dev/u/codeinabox in zig@programming.dev from atempleton.bearblog.devMigrating our DOM to Zig
5mon 5d ago by feddit.uk/u/vpol in zig@programming.dev from lightpanda.ioFinding and Fixing Ghostty's Largest Memory Leak
5mon 7d ago by lemmy.world/u/noumenon in zig@programming.dev from mitchellh.comWhy We Built Lightpanda in Zig
6mon 12d ago by programming.dev/u/codeinabox in zig@programming.dev from lightpanda.ioZig project leaves GitHub due to excessive AI
6mon 17d ago by mander.xyz/u/nemeski in zig@programming.dev from www.techzine.euI wrote my first zig program
6mon 18d ago by programming.dev/u/Vulwsztyn in zig@programming.devMigrating From GitHub to Codeberg, by andrewrk ():
6mon 19d ago by mas.to/users/frontenddogma in zig@programming.devMigrating from GitHub to Codeberg
6mon 22d ago by feddit.uk/u/vpol in zig@programming.dev from ziglang.orgZig 0.15.1 Released
9mon 12h ago by midwest.social/u/Type1 in zig@programming.dev from ziglang.org[video] Zig as a Multi-OS Build System (Interview with Loris Cro)
1y 10mon ago by programming.dev/u/mac in zig@programming.dev from www.youtube.comIntroducing pgzx: create PostgreSQL extensions using Zig
2y 2mon ago by programming.dev/u/mac in zig@programming.dev from xata.ioZig defer Patterns
2y 2mon ago by programming.dev/u/mac in zig@programming.dev from matklad.github.ioQOI Encoding in Zig
2y 3mon ago by lemmy.ml/u/gianni in zig@programming.dev from giannirosato.comWhy a language name is Zig?
2y 4mon ago by programming.dev/u/modev in zig@programming.devMatthew Lugg Joins the Core Zig Team
2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.orgDonor Bounty: Labeled Switch Continue Syntax
2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.orgAnnouncing Donor Bounties
2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.org2024 Financial Report and Fundraiser
2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.orggodot-zig/godot-zig: Zig bindings for Godot 4
2y 4mon ago by programming.dev/u/mac in zig@programming.dev from github.com







