|
Care for a slice of nested GOTO statements?
|
|
|
|
|
Global variables! Shirley you like global variables!
|
|
|
|
|
How could they possibly have omitted On Error Resume Next from the C# spec?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Simple problems should have simple solutions.
Complex problems should too.
|
|
|
|
|
Arrays start at 1 - just like when counting your fingers.
C# (C, C++...) messed up, who counts anything from zero? It's unnatural, zero simply does not exist.
Sin tack
the any key okay
|
|
|
|
|
Arrays in BASIC have always begun at zero... Though not many practitioners are smart enough to realize it.
|
|
|
|
|
Quote: zero simply does not exist. I have nothing to say to that!
...or in C#...
I have null to say to that!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Lopatir wrote: zero simply does not exist.
0 - Wikipedia[^]
Zero is a number and makes perfect sense to use it as an index in a collection/array.
|
|
|
|
|
Slacker007 wrote: makes perfect sense to use it as an index in offset into a collection/array
FTFY
|
|
|
|
|
Lopatir wrote: C# (C, C++...) messed up, who counts anything from zero? It's unnatural, zero simply does not exist.
Uhm, no. The understanding of the number zero was one of the most important discoveries to get mathmatics on the way and that was thousands of years ago. It's not at all as insignificant as you think. Except for BASIC fans, of course.
Then, you are confusing an index with counting. As any machine code or assembly programmer can tell you, you must address the first value in an array at BaseAddress + 0, and the nth value at BaseAddress + ((n-1) * sizeof(type)), or short: The index for the nth element always is (n-1). Except for BASIC fans, of course.
|
|
|
|
|
CodeWraith wrote: Except for BASIC fans, of course.
Some of whom refuse to acknowledge the existence of the zeroth element in their arrays even though it sits there sadly awaiting a value that will never arrive.
|
|
|
|
|
Indexing != counting, no discussion there. I assume that BASIC interpreters and compilers automatically adjusted the index. especially in the days of 8 bit computers they had no memory to waste.
|
|
|
|
|
Have you read the original 1964 spec of BASIC?
|
|
|
|
|
Was there a formal spec back then or has it been written afterwards as for most languages of that time?
|
|
|
|
|
|
There we go. The index values range from 0 to (n-1), as they should. Now at which point did they start with 1? Every early home computer had a BASIC interpreter in a ROM, which in most cases was a customized Microsoft BASIC. Atari developed the BASIC from scratch, and was zero based. Look here.[^] It has been some time since I used that manual, but I should still have it somewhere.
|
|
|
|
|
You may have misread the spec; page 38 says it's 0 to n inclusive. I expect that's why so many developers chose to use 1 to n inclusive and ignore element zero.
Show me a BASIC implementation that has 1-based indices (by default). I have never encountered one.
I do see that Turbo BASIC has an OPTION BASE statement that allows a developer to choose to differ from the default of zero. Turbo BASIC also extends the DIM statement to allow the developer to specify a range, similar to Pascal -- DIM b(50:60) . But the default behaviour is for 0 to n inclusive.
|
|
|
|
|
PIEBALDconsult wrote: 0 to n inclusive
Ok, but what's the reasoning behind that? You dimension an array to n elements and get an array with n + 1 elements.
This really is interesting. Back in the day I did not use BASIC very much. The interpreters were too slow, especially for graphics. When finally a C compiler fell into my hands (on the Atari ST), I never looked back. The whole thing sounds like a misunderstanding that came when everyone and their dogs started to write BASIC programs on their TRS-80s or later on their C64s.
|
|
|
|
|
CodeWraith wrote: You dimension an array to n elements
No, you dimension it for n+1, as per the spec.
|
|
|
|
|
DIM X(5)
n=5, so our array now should have six elements, indexed 0 - 5. Strange way of sying that you want six eggs, but ok. At least we use the same value to dimension the array and the highest valid index. In the end it is a just a question of specifications and conventions. However, the original problem was at the beginning of the array. Of course we could access the array with 1 - 6, but that would be even more confusing.
So, where do you think the habit to dimension the arrays one element too large, accessing them with 1 to n and wasting element 0 came into play?
I need a perfect, to the point answer as I am not aware of this.
Please don't reply explaining what method overloading is
|
|
|
|
|
Designers were ahead of their time maybe. And early practitioners weren't smart enough to grok the concept.
It reminds me of strings in Pascal -- you get a maximum of 255 characters preceded by how many characters are currently in the string.
'Tis possible that BASIC's designers had expected developers to use the zeroth element to hold the count of how many elements are in use.
|
|
|
|
|
I would tell you what the zeroth. finger is, but, I don't think you are ready, yet.
«Differences between Big-Endians, who broke eggs at the larger end, and Little-Endians gave rise to six rebellions: one Emperor lost his life, another his crown. The Lilliputian religion says an egg should be broken on the convenient end, which is now interpreted by the Lilliputians as the smaller end. Big-Endians gained favor in Blefuscu.» J. Swift, 'Gulliver's Travels,' 1726CE
|
|
|
|
|
|
To me, as a mathmatically inclined person, it really hurts taking the elevator in our new office building down to the basement: It goes: 4, 3, 2, 1, -1 ...!!! HEY! You dropped something! There is supposed to be something in between there!
I am equally upset about Christian churches - I don't know if it applies to all, but at least the Protestants in Europe and the Catholics officcialy number years "..., -2 (i.e 2BC), -1, +1, +2...). There are years before Christ and years after Christ, but no year "of Christ", i.e. the year of of his birth. This hurts my mathematical feelings.
|
|
|
|
|
Year Zero is a also a Leap Year.
|
|
|
|