POV-Ray : Newsgroups : povray.general : #declared Object Usage Server Time
1 Nov 2024 23:13:40 EDT (-0400)
  #declared Object Usage (Message 1 to 9 of 9)  
From: Ken
Subject: #declared Object Usage
Date: 30 Jun 1999 17:44:13
Message: <377A8F6D.EA252672@pacbell.net>
When did this become legal syntax and why ?

#declare B = box {-1,1}
 B

  I have always been under the impression a declared object needed
to be wrapped in an object statment to work properly.

e.g. object {B}

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Ron Parker
Subject: Re: #declared Object Usage
Date: 30 Jun 1999 17:52:17
Message: <377a9191@news.povray.org>
On Wed, 30 Jun 1999 14:43:09 -0700, Ken wrote:
>
>
>  When did this become legal syntax and why ?
>
>#declare B = box {-1,1}
> B
>
>  I have always been under the impression a declared object needed
>to be wrapped in an object statment to work properly.
>
>e.g. object {B}

It's not in the docs, therefore it's not technically legal.  But the 
toplevel parser basically says "If it's a directive or a camera or a 
few other top-level things, just do it, otherwise parse it as an object."

It's probably that way so light sources may be used wherever objects
may, such as in unions, and so that object{} blocks may be nested or
used within CSG with a little less work for the parser.  Don't ask me
to explain how I came to this conclusion.


Post a reply to this message

From: David Wilkinson
Subject: Re: #declared Object Usage
Date: 30 Jun 1999 18:04:34
Message: <377d92f1.14325766@news.povray.org>
On Wed, 30 Jun 1999 14:43:09 -0700, Ken <tyl### [at] pacbellnet> wrote:
>
>  When did this become legal syntax and why ?
>
>#declare B = box {-1,1}
> B
>
>  I have always been under the impression a declared object needed
>to be wrapped in an object statment to work properly.
>
>e.g. object {B}

Yes, this surprised me too Ken.  When I first saw the code I thought - this will
never work - but it did! It certainly isn't consistent, but I'm not sure that
it's bad.
David

------------
dav### [at] cwcomnet
http://www.hamiltonite.mcmail.com
------------


Post a reply to this message

From: Ken
Subject: Re: #declared Object Usage
Date: 30 Jun 1999 18:09:44
Message: <377A9568.2DB7F817@pacbell.net>
David Wilkinson wrote:
> 
> On Wed, 30 Jun 1999 14:43:09 -0700, Ken <tyl### [at] pacbellnet> wrote:
> >
> >  When did this become legal syntax and why ?
> >
> >#declare B = box {-1,1}
> > B
> >
> >  I have always been under the impression a declared object needed
> >to be wrapped in an object statment to work properly.
> >
> >e.g. object {B}
> 
> Yes, this surprised me too Ken.  When I first saw the code I thought - this will
> never work - but it did! It certainly isn't consistent, but I'm not sure that
> it's bad.
> David
> 
> ------------
> dav### [at] cwcomnet
> http://www.hamiltonite.mcmail.com
> ------------

There are limits to this insanity. For example this will not work for
what should be obvious reasons --

 #declare B = box {-1,1}
   B translate y*2

  I'm going to try a few other variations and see what if any other little
caveats are possible with this new found loophole. If I find anythig else
worth sharing I will post the results here.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Matt Giwer
Subject: Re: #declared Object Usage
Date: 1 Jul 1999 00:41:20
Message: <377AF180.A01913F1@giwersworld.org>
Ken wrote:

> There are limits to this insanity. For example this will not work for
> what should be obvious reasons --

>  #declare B = box {-1,1}
>    B translate y*2

object { B translate y*2} // works. 

	We appear to have a parser that permits two ways to accomlish
exactly the same thing. That is fine in mature applications but
is a disaster waiting to happen in parsers and compilers. (C has
already happened.) But mine is a purist point of view despite
being a lover of FORTH. 

-- 
<blink>-------please--don't-----------------</blink>

http://www.giwersworld.org/artsii/
http://www.giwersworld.org/artsiii/

Finally up on 99/06/22 updated 06/30


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

From: Margus Ramst
Subject: Re: #declared Object Usage
Date: 1 Jul 1999 07:11:11
Message: <377B4CF4.FE2407F6@peak.edu.ee>
Well, I've noticed this too, and never wondered. If it works, why bother?
It's not very useful, though, as you cannot modify the declared object upon
instancing.

Margus

Ken wrote:
> 
>   When did this become legal syntax and why ?
> 
> #declare B = box {-1,1}
>  B
> 
>   I have always been under the impression a declared object needed
> to be wrapped in an object statment to work properly.
> 
> e.g. object {B}
> 
> --
> Ken Tyler
> 
> mailto://tylereng@pacbell.net


Post a reply to this message

From: Ron
Subject: Re: #declared Object Usage
Date: 1 Jul 1999 18:22:29
Message: <377bea25@news.povray.org>
Ken wrote in message <377A9568.2DB7F817@pacbell.net>...
>
>
>David Wilkinson wrote:
>>
>> On Wed, 30 Jun 1999 14:43:09 -0700, Ken <tyl### [at] pacbellnet> wrote:
>> >
>> >  When did this become legal syntax and why ?
>> >
>> >#declare B = box {-1,1}
>> > B
>> >
>> >  I have always been under the impression a declared object needed
>> >to be wrapped in an object statment to work properly.
>> >
>> >e.g. object {B}
>>
>> Yes, this surprised me too Ken.  When I first saw the code I thought -
this will
>> never work - but it did! It certainly isn't consistent, but I'm not sure
that
>> it's bad.
>> David
>>
>> ------------
>> dav### [at] cwcomnet
>> http://www.hamiltonite.mcmail.com
>> ------------
>
>There are limits to this insanity. For example this will not work for
>what should be obvious reasons --
>
> #declare B = box {-1,1}
>   B translate y*2
>
>  I'm going to try a few other variations and see what if any other little
>caveats are possible with this new found loophole. If I find anythig else
>worth sharing I will post the results here.
>
>--
>Ken Tyler
>
>mailto://tylereng@pacbell.net

Hmm, I'm not really sure how the POV parser works but I can only imagine.
I'm guessing that by #declare'ing, you're defining a keyword for a whole
bunch of text. Now, everytime that word is encountered, it is simply
replaced by that text and the POV does its thing with it.
Thus, by declaring that box of yours and typing:
B
It probably simply replaces it with the text and then it works. But when you
type:

B translate y*2

It's like typing:
box {-1,1} translate y*2
Which is, of course, illegal by the POV language and that's why the object
keyword is required.
Again, this is just a guess after seeing how some other programmnig
languages work.
Hope this may have cleared thing a bit,

                        - Ron


Post a reply to this message

From: Ron Parker
Subject: Re: #declared Object Usage
Date: 1 Jul 1999 19:06:36
Message: <377bf356.281239491@news.povray.org>
On Fri, 2 Jul 1999 01:25:00 +0200, "Ron" <_exists_@_hotmail_._com_>
wrote:

>Hmm, I'm not really sure how the POV parser works but I can only imagine.
>I'm guessing that by #declare'ing, you're defining a keyword for a whole
>bunch of text. Now, everytime that word is encountered, it is simply
>replaced by that text and the POV does its thing with it.

Not exactly.  That's how macros work, roughly, but declare is
different.  It actually parses the text and stores it in a binary
form, which it copies to the appropriate place whenever the object
is invoked.  The biggest difference to the user is that the parser
finalizes the values of any variables at the time of declaration,
rather than at the time you use the object.

The discrepancy here is because the parser has been told that an
object is "any of those primitives like sphere, box, or whatever,
or a light_source, or the word 'object' followed by a block
containing an object (recursively defined), or an object_id, 
which is what you create when you #declare an object.  I think
it was done this way because it makes the recursive part easier,
among other things.  This weird syntax could be specifically
prohibited, but there's no real need.


Post a reply to this message

From: Chris Colefax
Subject: Re: #declared Object Usage
Date: 2 Jul 1999 10:16:38
Message: <377CCC92.8477DC6F@ledanet.com.au>
Ken wrote:
> 
>   When did this become legal syntax and why ?
> 
> #declare B = box {-1,1}
>  B
> 
>   I have always been under the impression a declared object needed
> to be wrapped in an object statment to work properly.
> 
> e.g. object {B}

Specifying an untransformed object identifier without the wrapper used
to be legal in POV-Ray 3.0, and I actually used it in a few sample
scenes for various include files.  When I started testing the files in
the early 3.1 beta versions, though, POV-Ray would give a fatal message
about a "lone R-Value".  Obviously, somewhere along the way this was
changed back to the previous flexibility... ours not to wonder why?!


Post a reply to this message

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