Author Topic: Admin List  (Read 2606 times)

Yes, but then there's this oddity..

If you set $con::warnUndefinedVariables to true and then type echo($test);, it will display $test as being undefined. However, if you type echo($test = "");, there will be no "undefined" warning. Even if you set the variable to "", the variable still exists and takes up memory until you call deleteVariables("$test");, so it's not exactly null.
Null in programming languages is 0x00. The keyword null that you're used to in other programming languages literally sets the value of a variable to 0x00, regardless of type. Torque doesn't have a null keyword, but it uses C Strings for its string values which are terminated by a null char (0x00) so a string with no value ("") is simply represented as 0x00.

There's a difference between undefined variables and variables that have null as their value. If you set $someVariable equal to "", it will be defined yet have a null value. However, Torque doesn't make you declare all variables before you can use and reference them. To get around the inevitable memory access error when you try to access a memory address that doesn't exist, it does a quick check for the variable and returns null if it doesn't exist. Because of this, we can use "" to check if a variable is undefined. However, this is irrelevant to the initial point. The initial point is that "" is a null value, which is generally referred to in computing as lacking a value.

Null in programming languages is 0x00. The keyword null that you're used to in other programming languages literally sets the value of a variable to 0x00, regardless of type. Torque doesn't have a null keyword, but it uses C Strings for its string values which are terminated by a null char (0x00) so a string with no value ("") is simply represented as 0x00.

There's a difference between undefined variables and variables that have null as their value. If you set $someVariable equal to "", it will be defined yet have a null value. However, Torque doesn't make you declare all variables before you can use and reference them. To get around the inevitable memory access error when you try to access a memory address that doesn't exist, it does a quick check for the variable and returns null if it doesn't exist. Because of this, we can use "" to check if a variable is undefined. However, this is irrelevant to the initial point. The initial point is that "" is a null value, which is generally referred to in computing as lacking a value.

Thanks for clarifying that for me. This all makes so much more sense in languages that actually have variable types and definitions and whatnot.

Thanks for clarifying that for me. This all makes so much more sense in languages that actually have variable types and definitions and whatnot.
Ah, no problem at all. It does make much more sense in more strongly typed languages, I'm actually not a huge fan of Torque completely leaving out variable types. I guess it makes it easier to learn and use, but at least you don't go adding strings and numbers together, lol.

Torque doesn't have a null keyword, but it uses C Strings for its string values which are terminated by a null char (0x00) so a string with no value ("") is simply represented as 0x00.

Lol.