Array Lower Bounds

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Dec 18 12:06:12 PST 2007


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:fk8ips$1jt$1 at digitalmars.com...
> Mike Marquard:
>> I know the default starting index for arrays is zero in D. But is there 
>> any way you can change the lower bounds to something other zero? For 
>> instance having the index go from 1 to 10 or say 100 to 200.
>
> Delphi, TurboPascal, and probably FreePascal have such feature, and once 
> in a while it's useful, see here for example:
> http://blogs.warwick.ac.uk/mtcharemza/entry/fortran_9095_versus_1
> but it's not difficult to adapt your mind to the fixed 0 starting point, 
> and you don't need to go looking at definition of the array type every 
> time to see what's the actual starting point of the array you want to use.

Thankfully D has slices and value types with overloadable indexing operators 
(though, as noted, without ref returns you can't *perfectly* emulate 
built-in arrays, though that will change), making it possible to emulate 
this rather .. niche feature. 




More information about the Digitalmars-d-learn mailing list