Undefined

Discussion in 'JS Plugin Requests' started by Mooshry, Jun 8, 2018.

Thread Status:
Not open for further replies.
  1. Mooshry

    Mooshry Ariana Grande has consumed my very existence help. Veteran

    Messages:
    362
    Likes Received:
    142
    Location:
    Your Air Conditioner
    First Language:
    Cow
    Primarily Uses:
    RMMV
    Can someone make a plugin where Undefined does something?
    Just so Undefined will have a function and i won't get that error anymore.
     
    #1
  2. JtheDuelist

    JtheDuelist Just a dev who actually got a game finished Veteran

    Messages:
    1,160
    Likes Received:
    1,423
    Location:
    RMW Forums, Granvia, or Askr
    First Language:
    English
    Primarily Uses:
    RMMV
    @Mooshry From the little amount of JS I've learned so far, Undefined is a JS function that is an error handler, so nothing can be done to turn Undefined into a functioning plugin feature.
     
    #2
  3. Nolonar

    Nolonar Veteran Veteran

    Messages:
    106
    Likes Received:
    112
    First Language:
    French, German
    Primarily Uses:
    RMMV
    Sorry, but that's impossible. If undefined did something or had a function, it would no longer be undefined. So even if you try to overwrite undefined with something, it would still be undefined. Even if it were possible to change undefined, that would be a very, very, very bad idea.

    When undefined throws an error, it's because you have a bug. If it stopped throwing errors, you'd still have the bug, but now you don't know where the bug happens.


    However, the biggest problem by far is that undefined doesn't always throws errors.
    You can for example do:
    Code:
    if (event) {
        // do something
    }
    If event is undefined, then the code inside the if branch won't execute. That's because undefined is not truthy (it doesn't evaluate to true).

    By adding a function to undefined, it would become an object (one that contains a function) and become truthy. This would break not only a large number of plugins, but might also completely break the RMMV core scripts as well.


    TL;DR
    Just don't do it.
     
    Last edited: Jun 8, 2018
    #3
  4. Mooshry

    Mooshry Ariana Grande has consumed my very existence help. Veteran

    Messages:
    362
    Likes Received:
    142
    Location:
    Your Air Conditioner
    First Language:
    Cow
    Primarily Uses:
    RMMV
    Oh. I didn't know anything about JS, so i thought undefined was just a thing that was there just chillin', waiting to be a function.

    (I can just imagine someone going like: Hey guys! I made undefined a function! And then everyone goes volcanic.)
     
    #4
  5. Nolonar

    Nolonar Veteran Veteran

    Messages:
    106
    Likes Received:
    112
    First Language:
    French, German
    Primarily Uses:
    RMMV
    Yes, that is correct.

    If you want to know more about how it could break things, I was just editing my previous response when you wrote this post.

    The bottom line is: you would indeed break a lot of things by defining undefined or even add a function to it.
     
    #5
  6. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,797
    Likes Received:
    7,616
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #6
Thread Status:
Not open for further replies.

Share This Page