POV-Ray : Newsgroups : povray.general : Arrays: integer in subscript? : Re: Arrays: integer in subscript? Server Time
7 Aug 2024 17:26:41 EDT (-0400)
  Re: Arrays: integer in subscript?  
From: Ron Parker
Date: 15 Aug 2001 23:16:51
Message: <slrn9nmep6.c2d.ron.parker@fwi.com>
On Wed, 15 Aug 2001 22:13:21 -0500, Bob H. wrote:
>"Ron Parker" <ron### [at] povrayorg> wrote in message
>news:slr### [at] fwicom...
>> On Wed, 15 Aug 2001 21:40:14 -0500, Bob H. wrote:
>> >They will become whole number positive integers 1 to N, at least from
>what I
>> >understand.  I was just looking into them once again and realized they
>are
>> >initialized as 1 to N yet are accessed as 0 to N-1.  I thought I recalled
>a
>> >discussion about that before and whether it should be changed.  Not sure.
>>
>> I don't recall seeing any subscripts in the initializer.  What do you mean
>> by "initialized as 1 to N"?
>
>Sorry, I don't know the terminology at all but I meant array[subscript]
>where subscript is initialized using 1 to N and then becomes 0 to N-1 when
>later accessed.
>Or do I have that all wrong?

I think you do.  When you initialize it, you say

#declare foo=array[size] {...}

Notice that that thing there is the size, not the last index, so it's not 
actually a contradiction.

Zero-based arrays are something that most programmers would be familiar 
with.  I think the assumption was that anyone using arrays probably either
has experience in another language or soon will, so they were kept zero-based
for the familiarity factor.  I can think of only a few obsolete dialects of
BASIC that use 1-based arrays.

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.