[fpc-pascal] a few trivial questions

spir ☣ denis.spir at gmail.com
Thu May 13 13:51:56 CEST 2010


On Thu, 13 May 2010 09:33:12 +0200
Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:

> spir ☣ het geskryf:
> >>> Also, is it possible to set a list's base index to 1 (so that
> >>> last_index=count)?
> >> No. That would break all other existing code.
> > 
> > I don't understand. If I set myList.baseIndex := 1, how can it affect
> > other people's code? It's a new feature that does not touch existing
> > codebase.
> 
> 
> At one point fpGUI switched all list type components to be 1-based. This
> caused such a lot of issues that I very quickly switched it back to
> 0-based. Why? Because even though my components were 1-based, the FPC lists
> where 0-based. So I had to very carefully keep track of which one uses what
> and often made mistakes. I personally hate 0-based counting because no
> human counts 0, 1, 2 etc.. so why must computers? But because 0-based is so
> standardized in programming languages, it's just easier to follow the crowd
> than fight them. :-)

Right, I'm aware of that (and also share your pov (*)); I just wanted to point that such flexibility does not affect external code. Not more, in fact, that
    array [i..j] of AType

Denis

(*) For a custom toy language, every kind of seq uses 1-based index and closed-interval section. This is very annoying when the implementation lang is 0-based and uses half-open intervals.
________________________________

vit esse estrany ☣

spir.wikidot.com



More information about the fpc-pascal mailing list