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

Explain in more detail what the hash function does in GlobalScope #10383

Open
HappyHeads opened this issue Dec 7, 2024 · 2 comments
Open

Explain in more detail what the hash function does in GlobalScope #10383

HappyHeads opened this issue Dec 7, 2024 · 2 comments
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement

Comments

@HappyHeads
Copy link

Godot 4.3

Currently the documentation only says that it "Returns the integer hash of the passed variable", someone who is new to coding might not understand what it means or where it should or should not be used. I think it should also state what algorithm it uses as it is not stated anywhere.

https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-hash

@AThousandShips
Copy link
Member

The internals of this method is an implementation detail and I don't think it should be made explicit

If people want specific hashing functions they should use the dedicated hashing classes instead I'd say

@tetrapod00
Copy link
Contributor

tetrapod00 commented Dec 7, 2024

I agree that the hash algorithm probably shouldn't be documented if it's not meant to be relied upon.

There might be a discrepancy here to resolve, though.
Object.get_instance_id() does say this:

Note: This ID is only useful during the current session. It won't correspond to a similar object if the ID is sent over a network, or loaded from a file at a later time.

@GlobalScope.instance_from_id does not have the note.
EncodedObjectAsID likewise does not have the note, but does say:

This class is used internally by the editor inspector and script debugger, but can also be used in plugins to pass and display objects as their IDs.

So there is potentially an improvement here by unifying the information from these multiple places, somehow. But we probably don't want to just copy the note verbatim, since that will increase maintenance later. I'm not familiar enough with the subject to make an improvement here, but leaving this here for anyone else who is.

@tetrapod00 tetrapod00 added the area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement
Projects
None yet
Development

No branches or pull requests

3 participants