POV-Ray : Newsgroups : povray.general : Few tricks : Re: Few tricks Server Time
12 May 2024 09:23:59 EDT (-0400)
  Re: Few tricks  
From: Bald Eagle
Date: 26 Nov 2023 09:10:00
Message: <web.65635113c0e3ff731f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> puzzled rather than critical :-)  why an array ?  eg
>
> #macro myMacro(p1,p2,p3,p4)
>   ...
>   (ret1, ret2, ret3)
> #end
>
> #declare (v,v2,v3) = myMacro(a,b,c,d);
>
>
> too works.

I used to use arrays, and sometimes vectors for this type of thing before clipka
implemented the tuple-style assignment.

WFP has been uncovering some interesting issues related to the tuple-style
assignment, and may be responsible for many of my hairs being ripped out in
bewilderment and frustration.

With an array, you have a nice, compact method of storing any number of values,
especially when using a mixed array.

Also, depending upon how the rest of the code is written, one can simply
#declare NewArray = MacroGeneratedArray ();
and be done with it.

Probably the most useful thing I can think of, at the moment, is that one can
cycle incrementally through all of the array elements with an iterator, whereas
you can't do any such thing with the tuple-style assignment.

You can also copy the entire array with a single line of code.

As with anything, it all depends on what you're doing, how far ahead you're
thinking, and just individual coding style.

- BW


Post a reply to this message

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