POV-Ray : Newsgroups : povray.unofficial.patches : Is it a BUG ??? declaring of Variables ... Server Time
1 Sep 2024 18:19:38 EDT (-0400)
  Is it a BUG ??? declaring of Variables ... (Message 1 to 6 of 6)  
From: walzer
Subject: Is it a BUG ??? declaring of Variables ...
Date: 2 Nov 2000 06:52:54
Message: <1103_973166133@saturn>
Hi ... I'm not sure if I'm right, and if I should post this here or 
in p.bugreports ...

I saw this behaviour still in MP06a but I detected it first Time in 
MP04 ... maybe it's the full MP-Codeline ...

I declared an Array :

		#declare A=array[100]

and in the following instruction I want to declare a variable, 
using the "$"-Operator I get an Errormessage ...

		$B=1;

Here iss my File:
>--------------------------------
#version unofficial MegaPov 0.3;

#declare a=array[16]
$b=1;

#include "stdenv.inc"
>-----------------

Running on MP04 I get 
the Output:

>--------------------
Parsing...This file was designed for (unofficial) MegaPov version 
0.3.  You are using version 0.4.
Some features may have changed.
#version unofficial MegaPov 0.3;

#declare a=array[16]
$ <----ERROR

bugtest.pov:4: error: object or directive expected but $ found 
instead.
>----------------------

When changing to

 #declare b=1;

everything is OK ....

Should it be posted to p.bugreports ???


Post a reply to this message

From: Ron Parker
Subject: Re: Is it a BUG ??? declaring of Variables ...
Date: 2 Nov 2000 11:17:57
Message: <slrn9034tn.gh.ron.parker@fwi.com>
On Thu, 02 Nov 2000 11:55:33 GMT, wal### [at] informatikuni-hallede wrote:
>Hi ... I'm not sure if I'm right, and if I should post this here or 
>in p.bugreports ...

[snip]

>Should it be posted to p.bugreports ???

p.bugreports is only for bugs in the official version.  This is the correct
place for bugs in custom versions.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Nathan Kopp
Subject: Re: Is it a BUG ??? declaring of Variables ...
Date: 3 Nov 2000 01:10:30
Message: <3a0256d6@news.povray.org>
<wal### [at] informatikuni-hallede> wrote...
> I declared an Array :
>
> #declare A=array[100]
>
> and in the following instruction I want to declare a variable,
> using the "$"-Operator I get an Errormessage ...
>
> $B=1;


Yes, this is known limitation (a bug that is too difficult to fix that I
won't bother).

The following three code snipets will work:

#declare a=array[16]
#declare b=1;

$a=array[16]
$b=1;

$a=array[16]
#declare b=1;  //I'm pretty sure this will work

The following one will not:

#declare a=array[16]
$b=1;

The problem occurs when you use of a #declare that does NOT end with a
semicolon, followed by a $.

Here is an explanation of why it acts this way and why I haven't fixed it:

All "#" directives in POV (such as #declare and #local) are handled
specially.  When the Get_Token() function (responsible for reading and
interpreting the character input) finds a "#" character, it interrupts what
it is doing and calls the Parse_Directive() function.  Regular scene parsing
is suspended until POV is done parsing the directive.

Now, just like the rest of the parser, Parse_Directive() uses Get_Token() to
get its tokens. This means that if POV wasn't careful, it could get a stack
overflow if you have a long string of #declares one right after another.
Why?  Well, if Get_Token() finds a "#" (such as in my first code snipet)
while it is parsing a #declare, it calls Parse_Directive().

The trick is to make Parse_Directive() contain a loop, and add a special
case for Get_Token() so it won't allow a re-entry of Parse_Directive().  If
Parse_Directive() is active and Get_Token() hits a "#", it will ignore it
and allow Parse_Directive() to take care of it.

I built this same looping capability into the "$" replacement for
"#declare".  However, the two loops are independent from each other.
Because of the way Parse_Directive() works, I'm pretty sure that you can
enter Parse_Directive() from my "$" replacement, but you can't go the other
way.

The best solution would be to force all #declares to end with a semicolon,
so the parser knows exactly when the directive is complete and it can return
from Parse_Directive() without having to have that messy loop and special
re-entry flag.  Of course, that would break more scenes, but I think it
would be best.  It would also add consistency to the parser, because now you
need a semicolon for #declaring floats and vectors, but you CANNOT have a
semicolon when declaring arrays, textures, pigments, etc.  That semicolon
would be useful for avoiding accidental layered textures, too.

-Nathan


Post a reply to this message

From: Warp
Subject: Re: Is it a BUG ??? declaring of Variables ...
Date: 3 Nov 2000 06:35:56
Message: <3a02a31b@news.povray.org>
This is one reason why all #declares in povray should end with a semicolon.

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


Post a reply to this message

From: David Fontaine
Subject: Re: Is it a BUG ??? declaring of Variables ...
Date: 4 Nov 2000 23:58:40
Message: <3A04E8B6.6788019@faricy.net>
Warp wrote:

>   This is one reason why all #declares in povray should end with a semicolon.

Agreed. I find that inconsistency annoying sometimes...

--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: GrimDude
Subject: Re: Is it a BUG ??? declaring of Variables ...
Date: 9 Nov 2000 23:12:22
Message: <3a0b75a6@news.povray.org>
"Nathan Kopp" <Nat### [at] Koppcom> wrote in message
>....  That semicolon
> would be useful for avoiding accidental layered textures, too.
>

I'm grinning...

Grim


Post a reply to this message

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