3 ms·
I disagree on many points the article makes, but it is well written and lays out its arguments well. One example - I prefer the named fields of Zig over Odin's
by com2kid 1y ago
I disagree on many points the article makes, but it is well written and lays out its arguments well.
One example - I prefer the named fields of Zig over Odin's use of positional fields. Zig's syntax is the more popular one as of late, heck even C has named struct member initialization.
IMHO Positional is just asking for trouble. Yes it works fine for game programming, and not having to specify x and y thousands of times in a code base is nice, but for general purpose languages where a struct can have a dozen+ fields to init, positional assignment is how bugs are made.
- lerno 1y agoC gives either, I think that is the true with Odin as well, it certainly is for C3. I was assuming Zig allowed both. Is this another one of Zig being strict with ”only one way”?
- Simran-B 1y agoYou can simply offer a function to create an object using positional arguments if you want that
- hansvm 1y agoYou can also create a function capable of doing that for any object, or one which curries the type parameter, if you'd like to reduce the boilerplate if you have many types of objects you'd like to instantiate positionally.
- hmac1282 1y agoI am only giving my impressions. Coming from other languages, this was very confusing, and the error messages were not helpful.