3 ms·
Pascal's arrays start at 1, at least by default.
by User23 4y ago
Pascal's arrays start at 1, at least by default.
- wvenable 4y agoPretty much all variants of BASIC have arrays starting at 1.
- JKCalhoun 4y agoI think a language needs to decide if it is "high level" or if it is instead a convenience language on top of assembly. BASIC and Pascal I am sure would have been considered a high-level language in their day and naturally would have arrays be 1-based. C on the other hand....
- hwayne 4y agoPascal is a variant of ALGOL-60, made in part because Wirth thought ALGOL-68 was way too complicated. BASIC instead comes from the FORTRAN line.
- sacrosancty 4y agoExcept VB.NET which is only 0-based but you can just shut your eyes and imagine it's 1-based because you declare an array by specifying its upper bound which equals its number of elements in 1-based.
- unnouinceput 4y agoThis is false. Pascal arrays start at whatever you want. As for what is happening behind closed doors (aka linker), those start at zero, but with an offset kept separately (that's why C blew out of the water Pascal in terms of speed when looping through an array). And in Pascal you cannot create a dynamic array with anything other than 0-based. You are confusing arrays with strings. Those used to start at 1, but since Unicode took over (~2007) strings are implemented as zero-based too (even though you can still think of them as 1-based when writing code). Also in Delphi, when creating a cross-platform application, strings are treated as 0-based, with even multiple locations in documentation stressing this importance due to having enough differences between classic VCL and the new kid on the block (aka FireMonkey).