-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Proposal: Rename comptime_int
and comptime_float
to anyint
and anyfloat
#7492
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
What about |
I think people will spend more time trying to figure out what's wrong with their |
What about Edit: |
That's good, actually. I like that better. |
comptime_int
and comptime_float
to int
and float
comptime_int
and comptime_float
to anyint
and anyfloat
(any time I talk about ints in this comment, read ints or floats) Naming them after these makes the whole Of course, this is why #5893 exists, but the suggestion above still implies |
this the only any* that this applies to. |
Uh oh!
There was an error while loading. Please reload this page.
EDIT: See @RaphiJS6-13 below for a better idea.
Minor part of #5895 that was not moved out following the post-#7396 purge. Remedying that now.
When a function takes an argument or a struct has a field of type
comptime_int
orcomptime_float
, the declaration is already annotated withcomptime
. A secondcomptime
in the type name just seems repetitive. Removing it would have psychological benefits as well: the types seem less like arcane compiler details and more like a normal, everyday part of code, which they are, and makes it more obvious why every literal requires a type (status quo: "What's the type of this? It's an int. All looks normal. compile error Excuse me? flips through docs Oh, yeah, it's acomptime_int
. Right."; this proposal: "What's the type of this? It's anint
. Oh, yeah, that's a comptime-only type, isn't it? Better coerce it.").There is precedent for this:
type
,anytype
and such are comptime-only (or have restrictions on their use), and do not have any special markings indicating this. Continuing this pattern withint
andfloat
I believe will be a valuable step toward normalising comptime in the minds of users. I think of it like this:comptime_int
andcomptime_float
sound like specialsed, arcane types, but they're actually in a way the most basic numeric types in the language, the types which coerce to all others. They should have suitably "basic" names.The text was updated successfully, but these errors were encountered: