-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Renaming @xtoy
to @YfromX
#16046
Renaming @xtoy
to @YfromX
#16046
Conversation
eh new conflict right before |
It's green! And second conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also renames
std.meta.intToEnum
tostd.meta.enumFromInt
, for simmetry. See also #15580.
Can you please omit this change from the patch? This way, this will be a breaking change, but one that can be completely migrated using zig fmt
. Let's handle intToEnum separately please (same logic from the linked issue applies here with regards to 1 break and not 2).
Other than this, I think this is a good time to make this breaking change. Thanks!
Thinking about it:
// It is a strange example but anyway.
const suitable_universe = (@intFromEnum(player1.universe) +| 2) == (@intFromEnum(player2.universe) -| 3);
// No need to read full line, at this point already know that "a" and b are some float
// const a = @float???
// const b = @float???
// ^^^^^^
const a = @floatFromInt(f32, @intFromBool(suitable_universe));
const b = @floatCast(f64, a * 2);
// Old version:
const a = @intToFloat(f32, @boolToInt(suitable_universe));
const b = @floatCast(f64, a * 2);
// Previously, you could've start writing your code by doing smth like this:
// const a = @intTo???(!!!, 1024);
// const a = @intTo
// It gives you some time to warmup and to think "what type do I want to get?",
// also, editor (most? of them) helps you to choose from auto-completion list.
// Now, you need to choose "output" type right at the beginning,
// and this action slows you down a bit.
// IDK if editors help you to auto-complete function from the end,
// I never used that option.
// Same when you edit this line to change "output" type again.
const a = @floatFromInt(f32, 1024);
// This does not affect "@intCast" and similar builtins,
// since one chooses them when both types are of same "family". |
Please note also #5909 which is accepted and affects your examples above. Regarding reading vs writing, the Zig language is all about reading and not writing, so there is an easy answer to this question. Reading wins. However, if you are not personally in favor of this change, then please don't force yourself to do it. |
Well, I am in favor of this change, it was just "for your information" to see if you'd change your mind (and I would not mind, it was a little effort with rename-and-test), and I'm looking ahead for merging :) |
Thwarted again! Let's try another run. (I am taking care of it) |
Signed-off-by: Eric Joldasov <[email protected]>
Signed-off-by: Eric Joldasov <[email protected]>
Note from Andrew: I re-ran update-zig1 on my pc and replaced this commit. Signed-off-by: Eric Joldasov <[email protected]> Signed-off-by: Andrew Kelley <[email protected]>
Thanks again! Was it because of security reasons (zig1.wasm update that is initiated by non-core team member)? |
It was yet another conflict that occurred while the CI was running |
* Update renamed builtins See: ziglang/zig#16046 * Update builtins to infer target type See: ziglang/zig#16163
The relevant changes are in these two PRs: ziglang/zig#16046 and ziglang/zig#16163. They change the cast builtins to infer the result type and change the order of the conversion builtins to `@xFromY` instead of `@yToX`.
I apologize in advance for such huge breaking changes.
"zig fmt" automatically renames
@xToY
to@yFromX
, but you can also invoke simplesed
stuff like:sed -i 's/@ptrToInt/@intFromPtr/g' whatever.zig
Also renamesdropped on @andrewrk 's request.std.meta.intToEnum
tostd.meta.enumFromInt
, for simmetry. See also #15580Closes #6128.