POV-Ray : Newsgroups : povray.object-collection : Compliance: local variable scope : Re: Compliance: local variable scope Server Time
27 Mar 2023 07:32:58 EDT (-0400)
  Re: Compliance: local variable scope  
From: Chris B
Date: 8 Jul 2008 19:10:05
Message: <4873f3cd$1@news.povray.org>
"SharkD" <nomail@nomail> wrote in message 
> In order for an object to be compliant, can I simply change all the 
> variables in
> the include file to local scope? Or, must I also rename them all using the
> object's abbreviation?
> I'm guessing that best practices is to do both.
> -Mike

The main objective is to avoid collisions with names chosen by someone using 
your include file, so in theory either would normally suffice and could be 
considered compliant. On the other hand, I've started using the unique 
prefix for the names of all identifiers (even local ones) because I noticed 
some circumstances where it removes some less usual potential conflicts.

Normally someone using your include file would simply include it in their 
own higher level scene file which should make using identifiers in your 
include file with a local scope quite safe. However, it's also possible that 
they may elect to do things a little differently, for example by adding 
their own stuff into your include file or by copying and pasting parts of 
your file into their own scene file. In these circumstances there is 
potential for the names you use in your local definitions to conflict with 
their own global declarations. I would therefore say that it is preferable 
to use the unique prefix everywhere as it makes it that little bit more 
robust in a wider range of circumstances.

Chris B.

Post a reply to this message

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