Reference Talk:Declare and Local Directives

From POV-Wiki
Revision as of 17:59, 13 December 2016 by Jholsenback (talk | contribs) (preserving some markup)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

preserving some deleted markup:

New in version 3.7.1: To circumvent the pitfalls of identifier name collisions, two pseudo-functions are provided to specifically refer to identifiers at either the global or the most local scope:

IDENTIFIER:
  GLOBAL_IDENTIFIER | LOCAL_IDENTIFIER | GENERIC_IDENTIFIER
GLOBAL_IDENTIFIER:
  global ( GENERIC_IDENTIFIER )
LOCAL_IDENTIFIER:
  local ( GENERIC_IDENTIFIER )

Both pseudo-functions can be used anywhere an identifier is allowed. They do not simply retrieve the cooresponding value, but refer to the identifiers themselves, allowing for constructs like the following:

#ifdef(local(Foo))
  #declare global(Foo) = Foo;
#else
  #undef global(Foo)
#end

This example tests whether the identifier Foo is in use at the most local scope, and if so, copies its value to the global variable of the same name; otherwise, it discards any value the global variable may have held before.