POV-Ray : Newsgroups : povray.general : parsing problem in POVRay Server Time
4 Nov 2024 19:20:51 EST (-0500)
  parsing problem in POVRay (Message 1 to 6 of 6)  
From: JC (Exether)
Subject: parsing problem in POVRay
Date: 2 Sep 2003 16:02:13
Message: <3f54f745$1@news.povray.org>
I think I found a potential bug that I couldn't find in the know bugs, 
so I report here, I hope it's the right group. Here is the code :

#macro Return_Int (A)
   #if (A>0)
     A
   #else
     0
   #end
#end

#local Var1=Return_Int (5);

You don't need any light or camera, POV-Ray complains that there should 
be a ';' at line 3 after the returned 'A' which I wouldn't expect. When 
I write :

#macro Return_Int (A)
   #if (A>0)
     A;
   #else
     0;
   #end
#end

#local Var1=Return_Int (5)

It works, but I see that more like a workaround than a correct syntax.

I hope it helps improving our worshiped POV,

JC


Post a reply to this message

From: Mike Williams
Subject: Re: parsing problem in POVRay
Date: 2 Sep 2003 16:22:03
Message: <RJeY8FAQsPV$Ewew@econym.demon.co.uk>
Wasn't it JC (Exether) who wrote:
>I think I found a potential bug that I couldn't find in the know bugs, 
>so I report here, I hope it's the right group. Here is the code :
>
>#macro Return_Int (A)
>   #if (A>0)
>     A
>   #else
>     0
>   #end
>#end
>
>#local Var1=Return_Int (5);

The conventional way of writing this so that POV accepts it would be to
put it in brackets, like this:

#macro Return_Int (A)
   #if (A>0)
     A
   #else
     0
   #end
#end

#local Var1=(Return_Int(5));

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Warp
Subject: Re: parsing problem in POVRay
Date: 2 Sep 2003 16:27:49
Message: <3f54fd45@news.povray.org>
"JC (Exether)" <no### [at] spamfr> wrote:
> #macro Return_Int (A)
>    #if (A>0)
>      A
>    #else
>      0
>    #end
> #end

  This is a typical place for making a mistake in the SDL syntax (and
perhaps would reserve an entry in the povQ&T page).
  The right way of doing this is:

#macro Return_Int (A)
   #if (A>0)
     #local retval = A;
   #else
     #local retval = 0;
   #end
   retval
#end

  The reason for this is because how the parser works... But it's a bit
too complicated for me to explain this late at night. :)

-- 
#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: Warp
Subject: Re: parsing problem in POVRay
Date: 2 Sep 2003 16:29:02
Message: <3f54fd8e@news.povray.org>
Mike Williams <mik### [at] econymdemoncouk> wrote:
> The conventional way of writing this so that POV accepts it would be to
> put it in brackets, like this:

  There's no need if you write the macro properly (as I explained in the
other post).

-- 
#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: Tim Nikias v2 0
Subject: Re: parsing problem in POVRay
Date: 2 Sep 2003 17:56:57
Message: <3f551229$1@news.povray.org>
Would you mind doing so someday in
the early morning? :-)

I'm just curious, that's all. Doing it like you
described for some time now, but never
got the technical answer why that is better...

Regards,
Tim

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights


> "JC (Exether)" <no### [at] spamfr> wrote:
> > #macro Return_Int (A)
> >    #if (A>0)
> >      A
> >    #else
> >      0
> >    #end
> > #end
>
>   This is a typical place for making a mistake in the SDL syntax (and
> perhaps would reserve an entry in the povQ&T page).
>   The right way of doing this is:
>
> #macro Return_Int (A)
>    #if (A>0)
>      #local retval = A;
>    #else
>      #local retval = 0;
>    #end
>    retval
> #end
>
>   The reason for this is because how the parser works... But it's a bit
> too complicated for me to explain this late at night. :)
>
> -- 
> #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: JC (Exether)
Subject: Re: parsing problem in POVRay
Date: 3 Sep 2003 02:13:24
Message: <3f558684@news.povray.org>
For beeing in computer programming I think I understand why the parser 
works this way, thanks for giving me way to make it work fine, it is the 
way every function returning value should be writen anyway, so that's 
cool, POV-Ray is actually enforcing good practices.  :-)

JC

Warp wrote:
> "JC (Exether)" <no### [at] spamfr> wrote:
> 
>>#macro Return_Int (A)
>>   #if (A>0)
>>     A
>>   #else
>>     0
>>   #end
>>#end
> 
> 
>   This is a typical place for making a mistake in the SDL syntax (and
> perhaps would reserve an entry in the povQ&T page).
>   The right way of doing this is:
> 
> #macro Return_Int (A)
>    #if (A>0)
>      #local retval = A;
>    #else
>      #local retval = 0;
>    #end
>    retval
> #end
> 
>   The reason for this is because how the parser works... But it's a bit
> too complicated for me to explain this late at night. :)
>


Post a reply to this message

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