That might be, but the motivating example isn’t one of those, the GPA can still be configured.
Consider the statement from the docs:
Default initialization of this struct is deprecated; use
.init
instead.
It makes just as much sense to say instead:
Default initialization of this struct is deprecated; use
.default
instead.
I don’t think that .default
is meaningfully better or worse than .initial
, but both are better than just .init
. I don’t like any ambiguity about whether something is a function or not. This is not only ambiguous, it cuts directly against an established convention. Zig has several rules and conventions to maintain that distinction, like snek_case
and camelCase
, function definition having a special syntax, and so on.
My second job had an ironclad rule against ever using value
or val
, closest thing to an exception was the k,v
pair for a fully-generic dictionary traversal function. That gives me a knee-jerk resistance to using it here, and for the same reason: one is suppose to ask “ok, but what value” and then use that instead, in this case, “initial value” or “default value” depending. It is closer to justifiable, I’ll grant you, because the word “value” appears in the answer to that question, which is uncommon.
It wouldn’t make sense to have two words like this, and while I don’t entirely share your feelings about using .default
in cases where there are no other valid options, I do take your point. So perhaps .initial
is the better choice. But if we’re going to keep init()
, initCapacity()
, zeroInit()
, and so on, I’d prefer to add the rest of the letters to the not-a-function value we’re discussing. Readability has always been a priority for the language, and this choice undermines that a bit.