POV-Ray : Newsgroups : povray.unofficial.patches : POV+for() Server Time
3 Sep 2024 04:15:14 EDT (-0400)
  POV+for() (Message 5 to 14 of 24)  
<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Nieminen Mika
Subject: Re: POV+for()
Date: 6 May 1999 09:08:37
Message: <37318645.0@news.povray.org>
Of course the syntax cannot be

#do
  ...
#while(...)

since you may want to put a regular #while loop inside the do-while loop.
Perhaps something like:

#do
  ...
#dowhile(...)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: J  Grimbert
Subject: Re: POV+for()
Date: 6 May 1999 09:27:09
Message: <37318A93.1EDBF5BF@atos-group.com>
TonyB wrote:
> 
> > The ++ is called the increment operator.
> > The -- is called the decrement operator.
> >
> > I don't see a burning need for these since they just add or subtract
> > one from the variable.
> 
> I see them as helpful in speeding up the parsing. Less text = less
> parsing (no?)

Not really, for instance the famous tree macro is short, and it take
ages to parse.
Parsing is not only reading the scene file, it's also creating the
memory representation of the scene.
If I were to agree with less text == less parsing, you have to remove
all
the comments, and all the blank lines (Wait, that's an idea, let's
remove
the carriage return/line feed : the one-line pov-scene !)

> 
> > There may be a use for *= and other compound operators, but still the
> > long version of what these accomplish gets the job done.
> 
> But it looks ugly.

Exactly what I thought on the first post: you are asking for cosmetic
changes.

<Extrem on>
 I would like the removal of sqrt(), instead you have to write 
   2^(1/2)   (or 2**0.5 ?)

 It's more like the formula in my math books. (fortran book ?)
<Extrem off>

> 
> > Regarding the for() loop, I usually just use this as an incrementing
> > loop anyhow which can be accomplished with the while loop by adding
> > an incrementer at the end. ie:
> 
> Your code was interesting, I've never done that. But still, the for would
> look neater, and is easier to write, at least for me.

It's just a cosmetic change.
Now, you can try to define a for() #macro for your personal usage.
something like:
#macro for(start,cond,inc,block)
start
#while(cond)
block
inc
#end
#end


Nota: I'm not sure this macro would ever work, or is even possible
Maybe it could be the real winner of the useless macro competition
(probably a higher complexity would help to gain some points...)


Post a reply to this message

From: J  Grimbert
Subject: Re: POV+for()
Date: 6 May 1999 09:31:02
Message: <37318B80.1AA8EFB7@atos-group.com>
Nieminen Mika wrote:
> 
>   Of course the syntax cannot be
> 
> #do
>   ...
> #while(...)
> 
> since you may want to put a regular #while loop inside the do-while loop.
> Perhaps something like:
> 
> #do
>   ...
> #dowhile(...)
> 

if you have something like

init
calcA
#while
calcB
calcA
#end

you can fold it like this:

init
#while 
#if (not first time) 
calcB
#end
calcA
#end

I do not see the need for #do/#dowhile


Post a reply to this message

From: Phil Clute
Subject: Re: POV+for()
Date: 6 May 1999 15:51:10
Message: <3731E610.9400E8A3@tiac.net>
>If I were to agree with less text == less parsing, you have to remove
>all
>the comments, and all the blank lines (Wait, that's an idea, let's
>remove
>the carriage return/line feed : the one-line pov-scene !)

Ken would be happy!
:-)

>Now, you can try to define a for() #macro for your personal usage.
>something like:
>#macro for(start,cond,inc,block)
>start
>#while(cond)
>block
>inc
>#end
>#end

This is interesting, I hadn't considered something like this. Of
course I think this just adds a step.

Phil

-- 
...coffee?...yes please! extra sugar,extra cream...Thank you.


Post a reply to this message

From: Phil Clute
Subject: Re: POV+for()
Date: 6 May 1999 15:59:22
Message: <3731E7FC.EB2D15A4@tiac.net>
I could have sworn POV had a #do-while directive. Obviously
I haven't tried to use it. Hmm? I must be crossing up my code
a bit...
I've always been curious as to why the pov-team chose #declare
over #define. I mean it doesn't make a difference really, I just
thought since POV is written in C it would be more comfortable
even for them.

Phil
-- 
...coffee?...yes please! extra sugar,extra cream...Thank you.


Post a reply to this message

From: Ralf Muschall
Subject: Re: POV+for()
Date: 6 May 1999 18:58:13
Message: <37321062.6D749378@t-online.de>
Nieminen Mika wrote:

> #declare Index+=1;
> #declare PosX*=1.5;
> #declare PosY/=2;
> #declare PosZ-=10;

Agreed, but I think ++ and -- are not necessary.
OTOH, I'd like to see the equality operator renamed from
= to == (I always get bitten by writing something like
#if(foo==bar)
and then having to correct it).

Another thing I'd like to see: The possibility of passing
the name of a macro as an argument to another macro.

This would allow one to e.g. create a triangle mesh for a
given function of two variables, where the name of the function
is given as the argument. Currently, the loop that makes
the mesh needs the name of the function hardcoded.

Ralf


Post a reply to this message

From: GrimDude
Subject: Re: POV+for()
Date: 6 May 1999 19:26:27
Message: <37321713.0@news.povray.org>
Aw, what we have now is fine!

I, too, get bit (heh) by things like this. At least you're not doing:

loop:
inc      ax,bitcount
cmp    cx,ax
jne      next_color
inc      cx,01d
jmp     loop

Well, it's been awhile. :)

GrimDude
vos### [at] arkansasnet


Post a reply to this message

From: TonyB
Subject: Re: POV+for()
Date: 7 May 1999 08:40:18
Message: <3732B3AB.107EE235@panama.phoenix.net>
>   I think there's no so much need for a #for statemen, but what I want to
> see in a future version of povray is a do-while statement, like this:

There's always a need for these things. It will allow POVers to be more
creative, and at least, it will help people like me, who think in _for_ and
not in _while_.

> #do
>   (something that will be made at least 1 time)
>   (make some calculations)
> #while(condition)
>
>   It's tedious to type:
>
> (make some calculations)
> #while(condition)
>   (something that will be made at least 1 time)
>   (make the same calculations here)
> #end

I don't understand what you mean about this being easier.

>   And of course some operators would be handy:
>
> #declare Index+=1;
> #declare PosX*=1.5;
> #declare PosY/=2;
> #declare PosZ-=10;

I'm glad you agree. ++ and -- would also come in handy (i.e. less typing).


Post a reply to this message

From: Nieminen Mika
Subject: Re: POV+for()
Date: 7 May 1999 09:36:55
Message: <3732de67.0@news.povray.org>
Phil Clute <pcl### [at] tiacnet> wrote:
: I've always been curious as to why the pov-team chose #declare
: over #define.

  Because #declared identifiers in povray are not macros, while #defined
identifiers in C are macros.
  The #macros in 3.1 work like #defines in C, but naming them as #define
instead of #macro would have been very confusing.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Nieminen Mika
Subject: Re: POV+for()
Date: 7 May 1999 09:38:43
Message: <3732ded3.0@news.povray.org>
J. Grimbert <jgr### [at] atos-groupcom> wrote:
: init
: #while 
: #if (not first time) 
: calcB
: #end
: calcA
: #end

: I do not see the need for #do/#dowhile

  Still you have to do extra typing, and the code gets slower since there's
one "unnecessary" #if statement to be computed.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>

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