POV-Ray : Newsgroups : povray.advanced-users : zero length arrays Server Time
24 Apr 2024 07:11:06 EDT (-0400)
  zero length arrays (Message 1 to 7 of 7)  
From: Mike Horvath
Subject: zero length arrays
Date: 4 Feb 2016 20:55:59
Message: <56b4012f$1@news.povray.org>
I'm trying to write a script that gets its objects from arrays. However, 
some of these arrays are empty, and cause parsing to stop. Why are zero 
length arrays not allowed? This is not true of most of the programming 
languages I am familiar with, and means I have to write a lot of extra 
code to handle this situation.


Mike


Post a reply to this message

From: clipka
Subject: Re: zero length arrays
Date: 5 Feb 2016 00:18:13
Message: <56b43095@news.povray.org>
Am 05.02.2016 um 02:56 schrieb Mike Horvath:
> I'm trying to write a script that gets its objects from arrays. However,
> some of these arrays are empty, and cause parsing to stop. Why are zero
> length arrays not allowed?

Because.


Post a reply to this message

From: scott
Subject: Re: zero length arrays
Date: 5 Feb 2016 02:43:20
Message: <56b45298$1@news.povray.org>
> I'm trying to write a script that gets its objects from arrays. However,
> some of these arrays are empty, and cause parsing to stop. Why are zero
> length arrays not allowed? This is not true of most of the programming
> languages I am familiar with, and means I have to write a lot of extra
> code to handle this situation.

In C# (which I mostly use) if there is any chance there will be zero 
elements then I normally use a List rather than an array. I believe 
there is something similar in C++, and probably in other languages too.


Post a reply to this message

From: dick balaska
Subject: Re: zero length arrays
Date: 5 Feb 2016 04:16:10
Message: <56b4685a$1@news.povray.org>
On 2/4/2016 8:56 PM, Mike Horvath wrote:
> I'm trying to write a script that gets its objects from arrays. However,
> some of these arrays are empty, and cause parsing to stop. Why are zero
> length arrays not allowed? This is not true of most of the programming
> languages I am familiar with, and means I have to write a lot of extra
> code to handle this situation.
>

If I have an array that may be of size 0, then I just don't define it 
and later check for #ifdef when I want to use it.


Post a reply to this message

From: Mike Horvath
Subject: Re: zero length arrays
Date: 5 Feb 2016 19:00:50
Message: <56b537b2@news.povray.org>
On 2/5/2016 4:16 AM, dick balaska wrote:
> On 2/4/2016 8:56 PM, Mike Horvath wrote:
>> I'm trying to write a script that gets its objects from arrays. However,
>> some of these arrays are empty, and cause parsing to stop. Why are zero
>> length arrays not allowed? This is not true of most of the programming
>> languages I am familiar with, and means I have to write a lot of extra
>> code to handle this situation.
>>
>
> If I have an array that may be of size 0, then I just don't define it
> and later check for #ifdef when I want to use it.
>

This means I will have to rewrite Chris Colefax's CityGen, since he uses 
arrays to store lots of stuff. :(


Post a reply to this message

From: Christian Froeschlin
Subject: Re: zero length arrays
Date: 5 Feb 2016 21:20:29
Message: <56b5586d$1@news.povray.org>
On 05.02.2016 8:43, scott wrote:

> In C# (which I mostly use) if there is any chance there will be zero
> elements then I normally use a List rather than an array.

Why? This seems perfectly legal in C#:

   double[] x = new double[0];
   Console.WriteLine(x.Length); // 0


Post a reply to this message

From: Thomas de Groot
Subject: Re: zero length arrays
Date: 6 Feb 2016 02:46:14
Message: <56b5a4c6$1@news.povray.org>
On 6-2-2016 1:01, Mike Horvath wrote:
> On 2/5/2016 4:16 AM, dick balaska wrote:
>> On 2/4/2016 8:56 PM, Mike Horvath wrote:
>>> I'm trying to write a script that gets its objects from arrays. However,
>>> some of these arrays are empty, and cause parsing to stop. Why are zero
>>> length arrays not allowed? This is not true of most of the programming
>>> languages I am familiar with, and means I have to write a lot of extra
>>> code to handle this situation.
>>>
>>
>> If I have an array that may be of size 0, then I just don't define it
>> and later check for #ifdef when I want to use it.
>>
>
> This means I will have to rewrite Chris Colefax's CityGen, since he uses
> arrays to store lots of stuff. :(

Then why does CityGen work in its original state? Or so I remember from 
the past...

-- 
Thomas


Post a reply to this message

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