Re: zero element array creation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Why isn't C/C++ more like BASIC/VB?".

Because BASIC wasn't intended to be used to write operating systems. Why
isn't a Mercedes-Benz more like the Ford Model-T since the Ford came first?

Before anyone launches in, that, of course, is purely rhetorical, but does
help to put things in perspective.

It's an odd perspective that suggests that modern things should be more like
the things cavemen used because they were first. Why aren't MP3s more like
33 1/3 LPs, can't they make them scratch and warp?

As for zero or 1 based indexing, we Homo Sapiens do not, intuitively start
count counting from zero.

Homo sapiens do not calculate divisions accurate to 64- bits nor do run at
65 MPH. These are machines. They aren't supposed to emulate people, we
have people for that.

You don't hear someone say "I've made my zeroth million.".

I hear them say "my bad" so this should be the error message when the CPU
overflows? :-)

Well, Tom, I follow everything you are saying here, but I do believe
that if VB is intended to be BASIC - Beginner's All-purpose Symbolic
Instruction Code, then BASIC really should count from 1.

Because it's FOR humans.

I don't personally care, myself, since I know how to count from 0. My
mind is wrapped around it, as is yours.

Maybe even for the star programmer starting out at 4 years old, its
best to have him understand 0-based indexing right away, but that's
not was BASIC was originally meant for.

Certainly, Option Base is no longer supported in VB.NET (2005), but arrays
are still 'sized' by supplying the value for the upper-bound, the same way
it has been since before C was invented.

The article points out (if I read it correctly) that the arrays are sized
one larger than expected. Expect a bank transfer error any day now and it
will be due to "oh yeah the array was one larger than we thought."

Exactly. The code could be accessing an out of bounds element, but
since you have 1 more than expected, you won't ever get the error
during debugging. Ouch.

And this is because when people type "10" they are thinking "length"
not "highest index". I think VB forcing us to think "highest index"
is absurd. AGAIN, they did it so that (most) older code will not
break. It's a trade off. That's why VB has mistakes like this. It's
ok to admit to them. It wouldn't have happened if VB6 didn't exist.

Saying it was always like this because of a coincidental truth that VB
arrays are always made by typing the 'highest index' doesn't negate
the truth of the matter. (And I'm not even sure if that coincidental
truth is actually true: When using Option Base 0, for old BASIC, did
you really state the array size by its highest index? or was it still
by array length?)

Zytan


.



Relevant Pages

  • Re: writing get_script()
    ... to the highest index. ... remove the first element from an array. ... print "$verse $script\n"; ...
    (comp.lang.perl.misc)
  • Re: Comments on parsing solution.
    ... keeps @files unique too; ... You don't need this function, though, as my code keeps the array ... "A teacher is never a giver of truth - he is a guide, a pointer to the truth that each student must find for himself. ...
    (comp.lang.perl.misc)
  • Re: Rich Comparisons Gotcha
    ... Traceback: ... The truth value of an array with more than one element is... ... It's this discrepancy that seems like a bug, not that a ValueError is raised in the former case, which is perfectly reasonable to me. ...
    (comp.lang.python)
  • Re: noob why doesnt this work question
    ... I'll just sort countarray so that the highest index value is first, ... perhaps that will take care of the problem! ... each specified array index. ... all the nils using Array#compact!, ...
    (comp.lang.ruby)
  • Re: Rich Comparisons Gotcha
    ... Traceback: ... The truth value of an array with more than one element is... ... It's this discrepancy that seems like a bug, not that a ValueError is raised in the former case, which is perfectly reasonable to me. ...
    (comp.lang.python)