POV-Ray : Newsgroups : povray.general : Types of datas in array Server Time
23 Dec 2024 06:28:03 EST (-0500)
  Types of datas in array (Message 1 to 3 of 3)  
From: kurtz le pirate
Subject: Types of datas in array
Date: 23 Sep 2018 05:02:29
Message: <5ba756a5$1@news.povray.org>
Hi,

I have declared this simple array :
   #declare MyArray  = array[n][3];

Then, i put some value on it :

   #declare MyArray[i][0] = 1.23456; float is OK
   #declare MyArray[i][1] = int(rand(alea)); integer is OK
   #declare MyArray[i][2] = rgb <a,b,c>; color not accepted.
                                         float required.

So, *all* the elements of the array must be of the *same type* ?
By design ?


regards
-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: Le Forgeron
Subject: Re: Types of datas in array
Date: 23 Sep 2018 05:05:50
Message: <5ba7576e$1@news.povray.org>
Le 23/09/2018 à 11:02, kurtz le pirate a écrit :
> Hi,
> 
> I have declared this simple array :
>   #declare MyArray  = array[n][3];
> 
> Then, i put some value on it :
> 
>   #declare MyArray[i][0] = 1.23456; float is OK
>   #declare MyArray[i][1] = int(rand(alea)); integer is OK
>   #declare MyArray[i][2] = rgb <a,b,c>; color not accepted.
>                                         float
required.
> 
> So, *all* the elements of the array must be of the *same type* ?
> By design ?

Yes. But you have an array of array here.

#declare MyArray = array[3][n];
and you can have it your way.


#declare MyArray[0][i] = 1.23456;


Post a reply to this message

From: clipka
Subject: Re: Types of datas in array
Date: 23 Sep 2018 08:44:55
Message: <5ba78ac7$1@news.povray.org>
Am 23.09.2018 um 11:02 schrieb kurtz le pirate:
> Hi,
> 
> I have declared this simple array :
>   #declare MyArray  = array[n][3];
> 
> Then, i put some value on it :
> 
>   #declare MyArray[i][0] = 1.23456; float is OK
>   #declare MyArray[i][1] = int(rand(alea)); integer is OK
>   #declare MyArray[i][2] = rgb <a,b,c>; color not accepted.
>                                         float
required.
> 
> So, *all* the elements of the array must be of the *same type* ?
> By design ?

Yes; the reason probably being that (a) that's how arrays worked in most
programming languages (and still does in a lot) when arrays were added
to POV-Ray, and (b) it allows to keep the memory overhead to a minimum
(which was important back in the days).


In v3.8.0, this restriction /should/ have been lifted, as I had
implemented support for mixed-type arrays in late 2016. And the code to
/handle/ mixed-type arrays is in there alright. Weirdly enough, and as
I'm noticing only right now, the code to actually /create/ mixed-type
arrays seems to never have made it into the repository.


Post a reply to this message

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