POV-Ray : Newsgroups : povray.general : #declared Object Usage : Re: #declared Object Usage Server Time
11 Aug 2024 15:14:54 EDT (-0400)
  Re: #declared Object Usage  
From: Ron Parker
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

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