Get Firefox! "my blog doesn't just deal with my life, it deals with some important stuff too"

9th of March 2006

VBScript: What A Wonderful Language

I wrote this script earlier to test a few ideas:

option explicit

execute("i = 3")

wscript.echo(i)

For those of you not familiar with VBScript, the "option explicit" command specifies that all variables must be explicitly declared. That is, you cannot print the contents of a variable that has not been declared correctly and within scope. The above code, however, runs without error and displays "3". I see two ways in which this ought to fail:

1. When the script is ran, when the compiler is making its initial checks to ensure that syntax looks correct and everything is declared correctly, the compiler should bomb out with an appropriate error about "i" not having been declared on line 3... because it hasn't; I'm using it without declaring it.

2. At run-time, on executing line 2, a run-time error should occur when the line "i = 3" is evaluated. The VBScript engine should detect that I am attempting to assign the value 3 to the variable i, which hasn't been declared elsewhere...

Yet more proof that VBScript is a toy language.

Blog #572, posted at 14:24 (GMT)