Skip to main content
added 83 characters in body
Source Link
Friedrich
  • 4.8k
  • 1
  • 17
  • 32

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although the use case in the question seems to be neither intended nor anticipated. I'd guess what you ask seems to workfor works mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

To sum it up: it will hurt Vim maintainers and script authors alike. The ability to write something that does not really make sense most of the time seems like a small price to pay in comparison.


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although what you ask seems to work mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

To sum it up: it will hurt Vim maintainers and script authors alike. The ability to write something that does not really make sense most of the time seems like a small price to pay in comparison.


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although the use case in the question seems to be neither intended nor anticipated. I'd guess what you ask for works mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

To sum it up: it will hurt Vim maintainers and script authors alike. The ability to write something that does not really make sense most of the time seems like a small price to pay in comparison.


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.

added 89 characters in body
Source Link
Friedrich
  • 4.8k
  • 1
  • 17
  • 32

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although what you ask seems to work mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

... and To sum it up: it will eventually leadhurt Vim maintainers and script authors alike. The ability to write something that does not really make sense most of the time seems like a question on this site "why can't I test if a script-variable exists()?"small price to pay in comparison.


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although what you ask seems to work mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

... and will eventually lead to a question on this site "why can't I test if a script-variable exists()?"


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although what you ask seems to work mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

To sum it up: it will hurt Vim maintainers and script authors alike. The ability to write something that does not really make sense most of the time seems like a small price to pay in comparison.


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.

Source Link
Friedrich
  • 4.8k
  • 1
  • 17
  • 32

Let's take a step back. Nowhere in :help exists() does it explicitly say you can check a script-variable. The section points to :help internal-variables where we learn that they come in many flavors, one of them being a script-variable. So, yes, you are correct. Although what you ask seems to work mostly for reasons of consistency—or: by accident—if you prefer to put it that way.

Rather than asking "what's the use of this edge case?" we should accept this as a necessary side-effect of language design. Any language with powerful-enough expressiveness will allow the creation of nonsensical statements. They are easily made up; take :if true—yet nothing keeps me from littering my code with it.

The alternative would be to add a test for a script-variable to the implementation of exists() which will:

  • increase complexity
  • reduce consistency
  • prevent the check in Maxim's answer

... and will eventually lead to a question on this site "why can't I test if a script-variable exists()?"


As a side note, the ability to create nonsense isn't restricted to artificial languages. Natural languages can be used to create nonsense as well, as evidenced by the Jaberwocky or, well, most political slogans.