POV-Ray : Newsgroups : povray.unofficial.patches : New feature idea : New feature idea Server Time
1 Sep 2024 22:18:03 EDT (-0400)
  New feature idea  
From: Warp
Date: 3 Oct 2000 05:39:48
Message: <39d9a963@news.povray.org>
How hard would it be to implement this feature:

  If an identifier appears in the script with a certain syntax, eg:

`identifier` or $identifier$ or #identifier# or whatever,

then that expression is substituted with the value of the identifier and
then parsing is continued exactly as if that value had been written
explicitly in that place.
  For example (supposing that we use for example the $$ notation) this:

#declare MyIdentifier = "Another"
#declare $MyIdentifier$ = 5;
#declare Something$Another$ = <1,2,3>;

would be parsed exactly as if we had written:

#declare MyIdentifier = "Another"
#declare Another = 5;
#declare Something5 = <1,2,3>;


  Why I propose this?
  There is a discussion in povray.general (IIRC) about how to avoid unnecessary
parsing of include files that are #included more than once.
  I thought that perhaps a macro could be done to automatize the ignoring
of repeated. This macro could be used like:

import("myinclude.inc")

which would #include "myinclude.inc" only if it wasn't included before.

  It's not easy to implement this macro with the current povray script.
Perhaps simulating some dynamic array and searching that array could be
done, but that's hard to do and very slow when there are lots of includes.
  Then I thought about the feature I propose here. The macro could be done
like:

#macro import(file)
  #local ID = strreplace(file, ".", "_");
  #ifndef(_INCLUDED_$ID_)
    #declare _INCLUDED_$ID$_
    #include file
  #end
#end

  (Note also the need for a 'strreplace' function or macro...)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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