POV-Ray : Newsgroups : povray.newusers : Is there a for operator? : Re: Is there a for operator? Server Time
28 Jul 2024 14:23:10 EDT (-0400)
  Re: Is there a for operator?  
From: Mathuin
Date: 9 Oct 2008 00:35:00
Message: <web.48ed8874ee785afd8a103ef0@news.povray.org>
andrel <a_l### [at] hotmailcom> wrote:
> Would you like to have arbitrary next item functions or just simply
> numeric increment?

I think arbitrary next-item functions are best.

If this is the example loop:

#declare Count=0;
#while (Count<MaxItems)
  blah(Count)
  #declare Count=Count+1;
#end // while (Count<MaxItems)

This form would be perfectly familiar to all the C users out there:

#for (Count=0; Count<MaxItems; Count=Count+1)
  blah(Count)
#end // for (Count=0; Count<MaxItems; Count=Count+1)

Other languages are different, of course, but C seems to be "common ground".

I don't think assignments, comparisons, or statements can be passed as macro
arguments, but if they could be, something like this would almost work:

#macro for(init, check, inc, body)
#declare init
#while (check)
  body
  #declare inc
#end // macro for

>
> > And in
> > SDL in particular I think most loops I've ever seen were actually
> > counter-based loops (placing objects, subdivide angles, arrays).

That's what I've seen in other source files -- wish I had more experience, but
I'm still the new guy. :-P


Post a reply to this message

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