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

Clarify type-safety of as #10781

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Clarify type-safety of as #10781

wants to merge 4 commits into from

Conversation

Lexyth
Copy link
Contributor

@Lexyth Lexyth commented Mar 18, 2025

Changed the statement about the as keyword's type-safety to clarify that it is less type-safe than type hints.

Changed the statement about the as keyword's type-safety to clarify that it is less type-safe than type hints.
@dalexeev
Copy link
Member

I find your correction useful in a practical sense, but imprecise in terminology.

Type safety means a guarantee that you won't get a type error at runtime. The as operator is more type safe, but also more error-prone.

The problem is that objects are nullable, null safety is not guaranteed by the current type system for objects.

@dalexeev dalexeev added enhancement discussion topic:gdscript area:manual Issues and PRs related to the Manual/Tutorials section of the documentation labels Mar 20, 2025
Changed the statement about the "as" keyword to clarify that it affects null-safety, not type-safety.
@Lexyth
Copy link
Contributor Author

Lexyth commented Mar 23, 2025

I find your correction useful in a practical sense, but imprecise in terminology.

Type safety means a guarantee that you won't get a type error at runtime. The as operator is more type safe, but also more error-prone.

The problem is that objects are nullable, null safety is not guaranteed by the current type system for objects.

I agree. I have edited it to clarify that: "[...] more :ref:type-safe<doc_gdscript_static_typing_safe_lines> than type hints, but also less null-safe [...]"

Used code-block format for "null" keyword.

Co-authored-by: Danil Alexeev <dalexeev12@yandex.ru>
Reduced the line length to make it more readable.

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation discussion enhancement topic:gdscript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants