VB10 vs VB6: Option Base
This is part of series of posts categorized under VB10 vs VB6.
"Option Base is not supported."
OK, time for a little history (extremely shortened). In the beginning, BASIC had 1 based arrays (May 1964). The creators of BASIC realized that this had certain limitations to it so about five months later when version 2 of the language was released (October 1964), the arrays changed from being 1 based to 0 based. Fast forward nearly 14 years (1978) and the language was going through the process of becoming a "standard" and the committee related to doing so fought among themselves until a compromise was made by creating OPTION BASE n so that the users of the language could decide for themselves what the base array number would be. However, 0 was chosen as the default. But wait, it gets more interesting when you fast forward another 6 years (1984) to yet another "standard" and they've changed the default from a 0 to a 1.
So you can see this issue has existed LONG before VB and will probably continue for a very long time. There are definately cases to support both arguments; however, one thing that is interesting to note is the following statement:
"But there was still a major problem for beginners. They shouldn't have to learn about the OPTION BASE statement, but they would be surprised when they used 'DIM X(10)' and got a list with eleven elements in it." -- Kemeny/Kurtz @ 1984.
So where does this leave us. First I have to state that this statement is, in fact, correct. OPTION BASE does not exist in VB10. However, I can somewhat see that since one of the major goals of .NET/CLS/CLR is to allow multiple languages to interoperate seemlessly with one another. An array in each of the supported languages works the same across all supported languages. OPTION BASE would require the VB compiler to have to do all sorts of translations, which I suspect would not be too much work to accomplish. However, if someone documented a method in VB using OPTION BASE 1 and someone in C#, F#, Ruby, Python, etc. were to try to utilize the result; they'd be left in bit of a quandry as to why array(0) exists.
However, let's say for argument sake that cross language isn't something a particular developer ever has to face. Let's say that this developer is going to only "consume" the produce and never produce anything that will be reused by anyone else. So in this case, it might be nice to have the ability to define the base of an array to be 0 or 1 depending on their specific needs. The problem that I've found is that circumstances seem to be so varied regarding when 0 or 1 seems to be the more natural choice that, at least to me, I find it simpler to keep the foundation at one level so that I know where I stand. Meaning, I know that an array always starts at 0 so all my code can be built as such.
I do also have to say I understand, and even agree, that it'd be nice to have the ability to create an array that has a more natural feel to it depending on the circumstances at hand. So....
At the end of the day, OPTION BASE probably isn't needed. The ability to define an array with a "custom" lower bound, on an array by array basis is what I would say would be a much more appropriate solution. VB10 has plenty of ways to accomplish this, of which I've already covered.
This discussion has been going on for 47 years now... so who am I to sway it one way or the other. With that said, technically VB10 does not have OPTION BASE, so it seems I have to give this one to VB6. However, as covered in the lower bound array post, VB10 has an incredible amount of flexibility in creating "arrays" / classes to better handle the specific needs with regards to a collection of information. So I leave this one as an excercise to the reader to draw thier own conclusion.