POV-Ray : Newsgroups : povray.general : does #break work as intended with #if statements? Server Time
6 Nov 2024 14:24:28 EST (-0500)
  does #break work as intended with #if statements? (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Shay
Subject: does #break work as intended with #if statements?
Date: 19 Aug 2002 14:19:19
Message: <3d6136a7$1@news.povray.org>
I expected that #break would ignore the #end in an #if statement and proceed
to the #end of the current #while loop, but this is not the case. Is this
intended?

An example:

#while (True)
  #if (True) #break #end
#end

Will loop forever. It would sure help speed up some code if this worked
differently. Is there a reason why #break behaves the way it does with #if
statements?

Just an additional thought. It would also be very cool if

 #while (condition & condition)

would not evaluate the second condition if the first were false. I think
that implementing this might cause a slow-down in code where the behavior
was not needed, however.

 -Shay


Post a reply to this message

From: Christoph Hormann
Subject: Re: does #break work as intended with #if statements?
Date: 19 Aug 2002 14:33:07
Message: <3D6139E2.C69ADD83@gmx.de>
Shay wrote:
> 
> I expected that #break would ignore the #end in an #if statement and proceed
> to the #end of the current #while loop, but this is not the case. Is this
> intended?
> 
> [...]

Why do you think #break is valid in #while or #if?

#break can only be use in #switch.

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Shay
Subject: Re: does #break work as intended with #if statements?
Date: 19 Aug 2002 14:41:08
Message: <3d613bc4$1@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote in message
news:3D6139E2.C69ADD83@gmx.de...
>
> #break can only be use in #switch.
>

That explains it then, doesn't it. I just assumed that it was valid because
it is a keyword used in other languages. Perhaps the use of this word will
be expanded in 4.0. Thank you.

 -Shay


Post a reply to this message

From: Le Forgeron
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 03:39:36
Message: <3D61F252.20203@free.fr>
Shay wrote:

> Christoph Hormann <chr### [at] gmxde> wrote in message
> news:3D6139E2.C69ADD83@gmx.de...
> 
>>#break can only be use in #switch.
>>
>>

And that's good enough.


> 
> That explains it then, doesn't it. I just assumed that it was valid because
> it is a keyword used in other languages. 


Because others do it is no excuse. The scene has to be described, not 
processed. There is no need for #break in #while/#if, if you can keep 
your mind on the right track.
I'm afraid someone come up with a "#goto" idea... followed by a blury 
"#continue"

>Perhaps the use of this word will
> be expanded in 4.0. Thank you.
> 


I hope and wish not!


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 05:28:03
Message: <3d620ba3@news.povray.org>
In article <3D6### [at] freefr> , Le Forgeron <jgr### [at] freefr>  
wrote:

> Because others do it is no excuse. The scene has to be described, not
> processed. There is no need for #break in #while/#if, if you can keep
> your mind on the right track.
> I'm afraid someone come up with a "#goto" idea... followed by a blury
> "#continue"
>
>>Perhaps the use of this word will
>> be expanded in 4.0. Thank you.
>
> I hope and wish not!

I agree.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Micha Riser
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 06:11:25
Message: <3d6215cd@news.povray.org>
Shay wrote:
> It would also be very cool if
> 
>  #while (condition & condition)
> 
> would not evaluate the second condition if the first were false. I think
> that implementing this might cause a slow-down in code where the behavior
> was not needed, however.

So now we are two wishing that pov would use short-circuit evaluation. It 
is still on my wish-list for 4.0. See 
http://news.povray.org/povray.general/18724/ for further discussion about 
it.

- Micha

-- 
http://objects.povworld.org - the POV-Ray Objects Collection


Post a reply to this message

From: Warp
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 09:28:29
Message: <3d6243fd@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
>>>Perhaps the use of this word will
>>> be expanded in 4.0. Thank you.
>>
>> I hope and wish not!

> I agree.

  I don't. #break and #continue would be useful inside loops. Without them
you have to make kludges which make parsing slower.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 09:40:05
Message: <3d6246b5@news.povray.org>
In article <3d6243fd@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   I don't. #break and #continue would be useful inside loops. Without them
> you have to make kludges which make parsing slower.

Not with properly designed algorithms ;-)

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Christopher James Huff
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 18:21:27
Message: <chrishuff-02B72D.17070020082002@netplex.aussie.org>
In article <3d6246b5@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> >   I don't. #break and #continue would be useful inside loops. Without them
> > you have to make kludges which make parsing slower.
> 
> Not with properly designed algorithms ;-)

I have occasionally found break useful, but rarely...I've never needed 
either one in POV. And I've never had to use continue.
In some cases I think using them is a good thing, I don't consider them 
a forbidden statement like goto. You just need to be sure you need them, 
and I don't think their absence is a problem for POV. Same as for and 
do-while loops: would be nice but isn't necessary.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: jfmiller
Subject: Re: does #break work as intended with #if statements?
Date: 20 Aug 2002 20:55:29
Message: <3d62e501@news.povray.org>
While not strictly necessary, it would be nice to have a C style "for" loop.
I've toyed around with the idea of implimneting it as a macro, but the
deliniators tend to get in the way.  Has anyone already done this?  If not
I'll keep working on my own.

JFMILLER

"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3d6246b5@news.povray.org>,
>  "Thorsten Froehlich" <tho### [at] trfde> wrote:
>
> > >   I don't. #break and #continue would be useful inside loops. Without
them
> > > you have to make kludges which make parsing slower.
> >
> > Not with properly designed algorithms ;-)
>
> I have occasionally found break useful, but rarely...I've never needed
> either one in POV. And I've never had to use continue.
> In some cases I think using them is a good thing, I don't consider them
> a forbidden statement like goto. You just need to be sure you need them,
> and I don't think their absence is a problem for POV. Same as for and
> do-while loops: would be nice but isn't necessary.
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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