POV-Ray : Newsgroups : povray.binaries.scene-files : PROOF : core include files and test code. : Re: PROOF : core include files and test code. Server Time
15 Aug 2022 15:48:32 EDT (-0400)
  Re: PROOF : core include files and test code.  
From: Bald Eagle
Date: 21 Mar 2022 15:25:00
Message: <web.6238d06326e475b01f9dae3025979125@news.povray.org>
Bruno Cabasson <bru### [at] yahoofr> wrote:

>  > extend() - not sure how far you will be able to .. bend SDL , but
> think that
>  > an important macro like extend should be "general".  clipka's advice
> wrt arrays
>  > was (paraphrasing) "if you know the #elements in advance, declare the
> array
>  > sized"; however, if I were to:
>  >    #declare A = array [2] {"a","b"};
>  >    #declare B = array [2] {"c","d"};
>  >    extend(A,B)
>  > I'd get: "Parse Error: Array subscript out of range".
>  >
> ===> You are correct. The use of some PROOF features may (and will)
> imply some restrictions. But that's highly secondary for me. In this
> particular case, I don't know if Sdl can detect if the array is of fixed
> sized. Please, enlighten me.

I don't think it can tell in a non-error triggering way.

Looking at your code,

#macro extend(arr, extension_arr)
    // We cannot know whether an array is "array" or "array mixed".
    // So we let the aprser generate an error if elements are of incompatible
    #local start = dimension_size(arr, 1);
    #for (i, 0, dimension_size(extension_arr, 1) - 1)
        #local arr[start + i] = extension_arr[i];

I think all you have to do is determine the size of both arrays, create a
temporary array of either dynamic size, or big enough to hold all the elements
of both, fill that array, and then declare the original array identifier name to
now be the new temporary array.

That would also let you get around the mixed array error, by making temporary
array a mixed type.

Post a reply to this message

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