POV-Ray : Newsgroups : povray.beta-test : Optional way to handle #include files? : Re: Optional way to handle #include files? Server Time
2 Jul 2024 10:12:55 EDT (-0400)
  Re: Optional way to handle #include files?  
From: Warp
Date: 30 Jul 2010 04:40:41
Message: <4c529009@news.povray.org>
Le_Forgeron <jgr### [at] freefr> wrote:
> And there is "cheating code" (but which I believe is still ok) like

> ================
> // file macro_begin.inc
> #macro Warp_Is_Great(a,n)
> sphere { .... }
> #include "macro_end.inc"

> //continue with scene description

> ================
> // file macro_end.inc"
> torus { .... }
> #end

> ================
> How would you cache that ? (and it can even be more trickier)
> Sometime tricky code is useful.

  The possibility of having part of the macro's body in a different file
(the macro definition block doesn't even need to be split into two files
as in your example, it's enough to simply have part of the macro's body
in a different file, inserted in the macro with an #include) makes the
caching slightly more complicated because "#include" needs to be handled
in a special way. In other words the "#include" command itself cannot be
cached, but instead it has to be interpreted while caching (so that what
ends up in the cache is not the "#include" command, but what it brings
to the macro definition). I don't see this is impossible.

  (Another option is that while transferring the macro to the memory
cache, if an "#include" is found, the macro is then marked as "uncacheable"
and then handled as macros are currently handled. The advantage of supporting
this is that if some other "trick" is later discovered which messes up with
the caching, the same solution can be used to fix the problem: If the problem
is found while caching, simply discard the caching of that macro and mark it
as "uncacheable".)

> Macro and loop came handy to avoid that.
> If you want to make cached macro, may I suggest you use some new keyword
> like #inline, with the added constraints that the end of the #inline
> must be in the same file as its beginning, and probably that you cannot
> redefined an already defined #inline.

  It's perfectly possible to detect, while parsing the macro, if it has
been split into more than one file, so the caching/non-caching can be
automatized. No need to introduce new keywords and functionalities into
the SDL.

-- 
                                                          - Warp


Post a reply to this message

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