Since both if object and if object!=null fail to distinguish deleted instances from undeleted instances, it seems like is_instance_valid(object) will be used a lot. Is there a way to shorten the function's name? Like how find_node shortens to $

If not, can someone make a feature request for it?

    I'm not sure that is a good idea for a proposal. The API works now and is fairly clear as to what the function does. Though I do understand that some of the API functions can be long, this is the price you pay for having readable code. I also never use $ it just feels like a hack to me.

    You can write any functions you want to make your life easier. Like this:

    func is_it(obj):
        return is_instance_valid(obj)
    ...
    if is_it(my_object):
        # do something

      cybereality

      I didn't think of that before, even though I have done lots and lots of coding in C++
      but instead of the underscore I would maybe just use isit() much quicker and less stress than the is_instance_valid() function name. The underscores is what slows down the typing and requires more muscle.

      I don't think it's an invalid question/request, but I also wouldn't be surprised if after opening a proposal the discussion there might steer towards some alternative solution that might perhaps turn out to be better. It's certainly worth opening a proposal for, given you've already searched to see if there isn't one of similar nature.

      I believe the feedback you'd get back from godot-proposals is to redefine it to your preference as suggested above; not a bad idea for any of the many lengthy built-ins you may use a lot. I think GDScript's clarity is worth it.

      For the complete convenience factor, if you want to use the same shorthand (and other functions) across many scripts, you could also create a class that includes your function instead of copying it into every script. 🐺

      I think I read that the developers were trying to remove is_instance_valid() as soon as possible anyway. It was a bandaid for an issue that should be fixed in gdscript 2.

        Sorry, I edited the other post, might have been in a bad mood. In any case, my point is that when you are learning a new library or language, you should aim to learn how and why it is done that way and try to adapt. Like if I am learning Japanese, the word for "I" is "私", which phonetically is "Watashi". To me, it seems kind of crazy to petition the Japanese government to tell them that "I" is a very common word and I think "Watashi" is too long. If that makes any sense.

        Also, I don't know what your level of programming experience is, but is_instance_valid() is a good function name and follows OOP practices. Granted, if you are using it all the time, yes, it is more code to write, but the code is clear and readable. But, if you are calling the same function all the time, it may mean there is an issue with your design. You can avoid writing duplicate code by defining your own functions with whatever names you like, you don't have to wait for people to alter the API.

        Beyond that, it's important to work with the environment you are in. Every language or engine or library has it's quirks, and learning them is part of the process. Unless we get to the point where you can type make an MMORPG in a cyberpunk universe; and the computer does it, then the programmer is always required to specify exactly what they want. This is the role of being a programmer. To explain object-oriented programming in full detail would take an entire book, but this page has a good summary on why the function is_instance_valid() is correct.

        https://www.codegrip.tech/productivity/how-to-write-good-code-by-creating-good-names-functions-objects-classes/

        DaveTheCoder

        I think this is what I was reading, or part of it. I followed the link to the issue, but I'm not sure what to make of it. It's a bit over my head.

        It was a little confusing, but I think I understand. is_instance_valid() did not go away (you can see it is still in the latest docs for 4.0) but it appears there was a memory bug in previous versions (but it was fixed around 2020, so should not be an issue today).

        From what I can understand, is_instance_valid() checks a memory address (pointer) for an object id. However there are edge cases where an object can be destroyed, but a new totally different object is create at the same memory address. While the object ids are different, it is still a valid instance of an object (just a different object than the original) meaning is_instance_valid() returns true, in error.

        To make things worse, there are additional checks for validity in debug mode (which is normal, that is why it is debug mode) but not in release. Meaning when testing your game it would work (you would never see the memory address bug) but after building your game it could happen (but it's still a rare edge case, you may not notice). So this is pretty bad. But it doesn't matter, since they fixed it 2 years ago.