POV-Ray : Newsgroups : povray.pov4.discussion.general : Caching parsed code : Re: Caching parsed code Server Time
26 Apr 2024 19:06:16 EDT (-0400)
  Re: Caching parsed code  
From: clipka
Date: 15 Apr 2009 16:40:01
Message: <web.49e644d0e0976a9b255d1edc0@news.povray.org>
C <the### [at] gmailcom> wrote:
> cache "grass"{
>    #declare a=0;
>    #while(a<100000)
>      placeGrass(a)
>      ...
>    #end
> }
>
> Pov Ray will automatically take the results and and save it to a file
> named grass.

Nice one. I already thought about saving already-parsed code (or even scene
objects) to be "quick-loaded" later, so that scene scripts could store interim
stuff and reload it later on demand. But using a mechanism to *automatically*
decide whether to generate or load the code... that'd be cool indeed.

Of course some mechanism should be in place to ensure that the pre-generated
stuff still matches, so it can re-run the code if something has been changed.
But I guess that should be rather easy to ensure by storing along with the
compiled stuff (1) some hash value of the respective source code (whitespace-
and comment-"neutral"), and (2) a table of variables accessed by that code
section, hashes of their values at the start of the code, and the actual values
of any variables changed / created / reset by the code.

For more flexibility, the syntax could be extended to include a version value,
which would be checked instead of the hash and all the variable values, so that
the code would only be re-run if the user updated that value.


Post a reply to this message

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