POV-Ray : Newsgroups : povray.general : The Language of POV-Ray : Re: The Language of POV-Ray Server Time
11 Aug 2024 09:28:28 EDT (-0400)
  Re: The Language of POV-Ray  
From: Nieminen Juha
Date: 12 Mar 2000 12:25:02
Message: <38cbd2ee@news.povray.org>
Chris Huff <chr### [at] yahoocom> wrote:
: There is a #break statement for switch statements, and from the 
: description, it doesn't seem like it would be too difficult to extend to 
: #if statments and loops.

  The #break-statement should NOT jump out of the current #if-statement, but
only out of the current #while-statement (and whatever else loop statement
this enhanced language would have).
  Why?
  Because usually you do this:

#while(whatever)
  ...
  #if(ending_condition)
    #break
  #end
  ...
#end

  It's obvious that if the #break just jumps out of the #if-statement, it
will be mostly useless.

  Unless...
  ... you could specify how many blocks do the #break jump out of. For
example:

#while(cond1)
  #while(cond2)
    #while(cond3)
      #if(cond4)
        #break(3)
      #end
    #end
  #end
  ...
#end

  Supposing that the #break also jumps out of the current #if-statement (and
it's counted as one block), the #break in this code will jump to the line
after the second last #end (ie. the line after the #while(cond2)-block,
marked with "...").

  Of course a simple #break that just jumps out of the current loop would be
mostly enough.

: Maybe even macros(have you ever wanted to jump 
: out of a macro early?)

  I don't know how this could be done. As far as I know, #macro is just
a text-replacement command. The macro call is just replaced with the body
of the macro with the parameters changed to their proper values.
  If you would #break a macro, it would mean that the body will literally be
broken, ie. with missing #end-statements (probably from the #if inside which
the #break was) thus causing problems to the parser.
  If macros were more like function calls, it would be more easier to add
a #return-statement.

  Now, that's an idea:

#function Abs(x)
  #if(x>=0)
    #return x
  #else
    #return -x
  #end
#end

  Hmm... Does this make sense? :)

-- 
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

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