POV-Ray : Newsgroups : povray.advanced-users : Break out of main while (1) loop using #break directive in a sub-loop state= : Re: Break out of main while (1) loop using #break directive in a sub-loop s= Server Time
5 May 2024 09:10:22 EDT (-0400)
  Re: Break out of main while (1) loop using #break directive in a sub-loop s=  
From: Bald Eagle
Date: 16 Jan 2023 14:55:01
Message: <web.63c5aaf77c2309d21f9dae3025979125@news.povray.org>
I will agree with everyone - certainly when I first saw that #while (1), my
first reaction was "WHAT.... THE .... ....."

I think that most of the #breaks are just poor coding practice meant to exit the
smaller loops early, not the outer while.

It's certainly interesting to learn more about this "short circuiting" and other
aspects of flow control code.  To my knowledge, no one has ever posted any SDL
code that illustrates the detailed behaviour of POV-Ray's SDL condition
evaluation.

One thing that I did run across that is being used in this code, but isn't
natively supported by SDL is the referencing of a 1D "slice" of a 2D array.

"Although it is permissible to reference an entire array as a whole, you may not
reference just one dimension of a multi-dimensional array."

https://wiki.povray.org/content/Reference:Array

So I made a macro as a workaround for that, in case anyone has any need to do
such a thing.  Basically, it just takes the array and whatever element of the
first dimension that you want to use and copies that into a smaller "2D" array,
which can then get passed as an argument to a macro.


#macro Reference2DSubarray (Array, Index)
 #local Size = dimension_size (Array, 2);
 #local Temp = array[1][Size];

 #for (i, 0, Size-1)
  //#debug concat ("i = ", str (i, 0, 0), "\n")
  #local Temp[0][i] = Array[Index][i];
 #end
 Temp
#end


I'll see if I can do any debugging or high-level perusal of the code and make
any progress - otherwise it might be another lost cause since I have yet to
determine what it actually DOES.


Post a reply to this message

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