what did you discover to explain these occurrences of the dot?
I guess I discovered that learning what the dot does depends a lot on the programmer to interpret the environment it’s being used. That’s why when learning the language can feel a bit confusing (though is not 1.0 release yet, so maybe it’s on me). But instead of using dot for many different operations, using a different symbol to express a specific operation could be useful ? (Just an opinion)
And even though I don’t use LLM to write code, it’s being one of the few resources I can reason with for learning Zig, like “explain me this” , “why doesn’t it work like that”, “how to understand what this function wants”… ? It gives me wrong answers all the time too, but helps pointing in a direction.
Maybe in the future std
can include copy-paste examples for every function.
I believe this syntax is borrowed from C’s designed initializer syntax. If not borrowed, it looks a lot like it
Yes, I had a similar thought, which is also why I was expecting ->
for pointer member access. Instead of being just able to solve .
At first glance these dots seem unnecessarily verbose
DroneEngine{ .key="E2", .health=95, .rpm=0, .stat=.off },
(and the .off omission can be a stretch, if you are just learning)
Can anything else be there that would require the dot notation to resolve the field ? Or it’s just really borrowed syntax to help transition from expected C developers ?
If you don’t deref it, or if your data in the engine is not possible to be simply copied, it will refer it.
Hi, are you saying that .*.health
and .health
behave differently in the language ? If so can you demonstrate with a piece of code I can try as well ? Otherwise, if both provide the same end behavior, is the .*
notation needed ?
And if you make a function with mutable inputs, they have to be pointer.
Ah, this is useful, thanks!