Skip to content
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

Improve documentation of int #70046

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

MewPurPur
Copy link
Contributor

@MewPurPur MewPurPur commented Dec 14, 2022

Main description:

  • Explained float->int and int->float conversions in the description.
  • Added a note about int in boolean context.
  • Explained GDScript's separators _ and binary/hex literals 0b and 0x.

The rest of the page:

  • Followed how other classes are documented more closely.
  • Shortened the line count of examples dramatically, using one good example to demonstrate each basic concept.
  • Fixed typos and misteaks.
  • Used 0b to explain bitwise operators.
  • Misc.

Changed how operator descriptions are worded:

  • int + float -> "the int", "the float"
  • int + int -> "the two ints" / "the left int", "the right int"

@MewPurPur MewPurPur requested a review from a team as a code owner December 14, 2022 06:56
@Chaosus Chaosus added this to the 4.0 milestone Dec 14, 2022
@MewPurPur MewPurPur force-pushed the improve-number-docs branch 3 times, most recently from b17b4df to d3b2b8b Compare December 14, 2022 22:39
doc/classes/int.xml Outdated Show resolved Hide resolved
@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 10, 2023
doc/classes/int.xml Outdated Show resolved Hide resolved
max_int += 1
print(max_int) # -9223372036854775808, we overflowed and wrapped around.
var x: int = 1 # x is 1
x = 4.2 # x is 4, because 4.2 gets truncated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you removed the mention of type hints from the above text, we should probably mention it in the code sample. Particularly since var x = 1 would also work and be an integer, the difference is that it would change the behavior of x = 4.2, with the hint it's casted to 4, without it stores the float 4.2. We want to inform users that : int is not a required part of using the integer type.

Copy link
Contributor Author

@MewPurPur MewPurPur Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't know how to do this gracefully. While we wouldn't want to explain how static typing works here, we do want to explain the whole back-and-forth between int and float (for example how passing an int to a function that accepts a float will just do an appropriate conversion). Maybe I could explain that this also holds for statically-typed vars as an example?

doc/classes/int.xml Outdated Show resolved Hide resolved
doc/classes/int.xml Outdated Show resolved Hide resolved
doc/classes/int.xml Outdated Show resolved Hide resolved
doc/classes/int.xml Outdated Show resolved Hide resolved
@YuriSizov YuriSizov merged commit 868fcfd into godotengine:master Mar 27, 2023
@YuriSizov
Copy link
Contributor

This is great, thanks!

@MewPurPur MewPurPur deleted the improve-number-docs branch March 27, 2023 16:05
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants