-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
proposal: differentiate between "field" and "decl" with @field #3839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Agree it should be split. Also would be nice to have all three ( Edit: Or perhaps it'd be more extensible to specify the type with the Why are these builtins at all instead of just some fn defined in |
IIRC the reasoning is that the 'has' functions in std.meta are inefficient because they require comptime looping over TypeInfo and this case was common enough to warrant a more efficient builtin. |
I stumbled on this today while reading the documentation:
but
I agree this is really confusing and unexpected for newcomers. |
This was discussed at the end of #1439.
In that issue the proposed
@hasField
builtin was split into@hasField
and@hasDecl
in order to differentiate between struct instance fields and struct namespaced declarations.It is further proposed that
@field
either be altered in the same manner:@field
/@decl
or be renamed to make it clear that it refers to any "member" of a struct regardless of which it is (@member
). My personal preference is the former.related: #1836
The text was updated successfully, but these errors were encountered: