Zig

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.org
602

Error Handling Guide — try, catch, errdefer

3mon 29d ago by lemmy.world/u/monica_b1998 in zig@programming.dev from slicker.me
403

Lessons from Zig

4mon 6d ago by programming.dev/u/codeinabox in zig@programming.dev from www.vinniefalco.com
204

Today participating at the Zig Day event in Nuremberg: https://zig.day/europe/nuremberg/

4mon 10d ago by mastodon.social/users/sourcefranke in zig@programming.dev
605

Zig and the M×N Supply Chain Problem

4mon 19d ago by programming.dev/u/codeinabox in zig@programming.dev from nesbitt.io
506

I 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.dev
1107

Migrating our DOM to Zig

5mon 5d ago by feddit.uk/u/vpol in zig@programming.dev from lightpanda.io
108

Finding and Fixing Ghostty's Largest Memory Leak

5mon 7d ago by lemmy.world/u/noumenon in zig@programming.dev from mitchellh.com
709

Why We Built Lightpanda in Zig

6mon 12d ago by programming.dev/u/codeinabox in zig@programming.dev from lightpanda.io
15110

Zig project leaves GitHub due to excessive AI

6mon 17d ago by mander.xyz/u/nemeski in zig@programming.dev from www.techzine.eu
73811

I wrote my first zig program

6mon 18d ago by programming.dev/u/Vulwsztyn in zig@programming.dev
7012

Migrating From GitHub to Codeberg, by andrewrk ():

6mon 19d ago by mas.to/users/frontenddogma in zig@programming.dev
4013

Migrating from GitHub to Codeberg

6mon 22d ago by feddit.uk/u/vpol in zig@programming.dev from ziglang.org
29114

Zig 0.15.1 Released

9mon 12h ago by midwest.social/u/Type1 in zig@programming.dev from ziglang.org
3015

[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.com
6016

Introducing pgzx: create PostgreSQL extensions using Zig

2y 2mon ago by programming.dev/u/mac in zig@programming.dev from xata.io
6017

Zig defer Patterns

2y 2mon ago by programming.dev/u/mac in zig@programming.dev from matklad.github.io
6018

QOI Encoding in Zig

2y 3mon ago by lemmy.ml/u/gianni in zig@programming.dev from giannirosato.com
7019

Why a language name is Zig?

2y 4mon ago by programming.dev/u/modev in zig@programming.dev
3120

Matthew Lugg Joins the Core Zig Team

2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.org
6021

Donor Bounty: Labeled Switch Continue Syntax

2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.org
3022

Announcing Donor Bounties

2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.org
3023

2024 Financial Report and Fundraiser

2y 4mon ago by programming.dev/u/mac in zig@programming.dev from ziglang.org
9024

godot-zig/godot-zig: Zig bindings for Godot 4

2y 4mon ago by programming.dev/u/mac in zig@programming.dev from github.com
8025