POV-Ray : Newsgroups : povray.general : Parse Error: No matching } in 'union', object identifier found instead Server Time: 19 Feb 2019 23:28:58 GMT
  Parse Error: No matching } in 'union', object identifier found instead (Message 1 to 5 of 5)  
From: kendfrey
Subject: Parse Error: No matching } in 'union', object identifier found instead
Date: 21 Jan 2019 00:05:00
Message: <web.5c450a7271c191d5c059c35f0@news.povray.org>
I'm getting this error when trying to create a union of predefined objects.

--------------------------------------------------
#declare Foo = sphere { <0, 0, 0>, 0.1 };
#declare Bar = sphere { <1, 0, 0>, 0.1 };
union
{
    Foo
    Bar // Parse Error: No matching } in 'union', object identifier found
instead
}
--------------------------------------------------

This seems like it should be fine. It parses successfully if I put each
identifier inside object { }. Why isn't this allowed?


Post a reply to this message

From: clipka
Subject: Re: Parse Error: No matching } in 'union', object identifier found instead
Date: 21 Jan 2019 08:52:04
Message: <5c458834$1@news.povray.org>
Am 21.01.2019 um 01:00 schrieb kendfrey:
> I'm getting this error when trying to create a union of predefined objects.
> 
> --------------------------------------------------
> #declare Foo = sphere { <0, 0, 0>, 0.1 };
> #declare Bar = sphere { <1, 0, 0>, 0.1 };
> union
> {
>      Foo
>      Bar // Parse Error: No matching } in 'union', object identifier found
> instead
> }
> --------------------------------------------------
> 
> This seems like it should be fine. It parses successfully if I put each
> identifier inside object { }. Why isn't this allowed?

It's just how POV-Ray's language rolls: Pretty much wherever you use a 
non-trivial variable (i.e. not a number, vector, colour or string), you 
need to wrap that variable into a statement telling POV-Ray what to 
expect in that variable.

For example, consider the following code:

     union {
         Foo
         Bar
         Fnord
     }

If such code were allowed, you would have to take a closer look at the 
variable `Fnord` to tell whether it is supposed to be another object, or 
rather e.g. a texture, transformation or what-have-you.

As for why it was designed this way, I can only speculate; it might have 
been intended to make scenes easier to read for humans (back in the days 
when good variable names were short and cryptic), or easier to read for 
the parser.

At any rate, this syntax quirk has survived the ages, and nobody has 
ever bothered enough to actively do anything about it.


Post a reply to this message

From: kendfrey
Subject: Re: Parse Error: No matching } in 'union', object identifier found instead
Date: 21 Jan 2019 12:10:01
Message: <web.5c45b60379c392cec059c35f0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> It's just how POV-Ray's language rolls: Pretty much wherever you use a
> non-trivial variable (i.e. not a number, vector, colour or string), you
> need to wrap that variable into a statement telling POV-Ray what to
> expect in that variable.
>
> For example, consider the following code:
>
>      union {
>          Foo
>          Bar
>          Fnord
>      }
>
> If such code were allowed, you would have to take a closer look at the
> variable `Fnord` to tell whether it is supposed to be another object, or
> rather e.g. a texture, transformation or what-have-you.
>
> As for why it was designed this way, I can only speculate; it might have
> been intended to make scenes easier to read for humans (back in the days
> when good variable names were short and cryptic), or easier to read for
> the parser.
>
> At any rate, this syntax quirk has survived the ages, and nobody has
> ever bothered enough to actively do anything about it.

Oh well, it's nice to know I wasn't just doing something dumb. Thanks!


Post a reply to this message

From: Kenneth
Subject: Re: Parse Error: No matching } in 'union', object identifier found instead
Date: 21 Jan 2019 13:10:00
Message: <web.5c45c46879c392cecd98345b0@news.povray.org>
"kendfrey" <nomail@nomail> wrote:
> I'm getting this error when trying to create a union of predefined objects.

A simpler form of this quirk actually does work:
#declare Foo = sphere { <0, 0, 0>, 0.1 };

Foo // no object wrapper needed

But I don't know if this trick works if there is any intervening code between
the #declare and Foo. Give it a try ;-)


Post a reply to this message

From: clipka
Subject: Re: Parse Error: No matching } in 'union', object identifier found instead
Date: 21 Jan 2019 15:59:50
Message: <5c45ec76$1@news.povray.org>
Am 21.01.2019 um 14:08 schrieb Kenneth:
> "kendfrey" <nomail@nomail> wrote:
>> I'm getting this error when trying to create a union of predefined objects.
> 
> A simpler form of this quirk actually does work:
> #declare Foo = sphere { <0, 0, 0>, 0.1 };
> 
> Foo // no object wrapper needed
> 
> But I don't know if this trick works if there is any intervening code between
> the #declare and Foo. Give it a try ;-)

Don't get used to it.

This works at the scene level, but not inside unions or the like. 
Instead, when you use

     #declare Foo = sphere { ... }
     union { Foo }

this only works because it happens to be interpreted as

     #declare Foo = sphere { ... }
     object { Foo }

Also, this only works with a limited number of object keywords, and only 
as an unintended side effect. The originally intended syntax seems to 
have been:

     #declare Foo = sphere { ... }
     sphere { Foo }

     #declare Bar = box { ... }
     box { Bar }

     #declare Fnord = union { ... }
     union { Fnord }

This may have been the oldest form of the syntax, and `object` may have 
been introduced later as an afterthought, to serve as a common alias for 
`sphere`, `box`, etc. in such contexts.

This is just speculation though, and I'm not sure if even David K. Buck 
remembers how this syntax feature evolved. In DKBTrace 2.01 (1990), it 
had already taken pretty much the shape we see today.


Post a reply to this message

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