|
|
clipka <ano### [at] anonymousorg> wrote:
> Am 21.04.2018 um 21:30 schrieb Alain:
>
> > If you use any macro in a loop, it will get expanded and parsed each
> > time it's used.
> >
> > If that macro is in an include file, that file will get opened and read
> > each time the macro is invoked.
>
> As of v3.8.0-alpha, this is no longer true: Macros up to a certain size
> (currently hard-coded to, IIRC, 64 kiB) are now cached in memory.
Thanks for the clairification about macro caching. I know it's been mentioned
before, but I wasn't clear about the details-- the exact memory limit. I
assume(?) that the caching occurs for *any* entity placed in the macro... even a
pigment{image_map...} for example (just so it's under the 64K limit).
>
> > EVERYTHING before the macro definition
> > need to be read and skipped. Example : If you use any colour
> > manipulation macro from colors.inc, they are located at the end, forcing
> > the parser to read the whole include every time they are used.
>
> That's not true even for v3.7 and earlier: The parser does remember the
> offset of the macro within the include file, and jumps directly to that
> offset when executing the macro.
I didn't know that; a VERY useful bit of info.
And Clipka said...
> Every reasonably fast contemporary programming language makes use of at
> least /some/ degree of compilation. For instance, functions, procedures
> and/or classes might use proper compilation, or at least "compiled" into
> an internal intermediate representation that is faster to interpret.
>
> POV-Ray's parser is a genuine interpreter. No compiling going on /at
> all/ (*)
>
> (* Except for user-defined functions. Those are compiled into bytecode
> for a proprietary virtual machine.)
William F Pokorny mentioned something about this in an earlier thread, but it
'slipped through my radar' at the time...
http://news.povray.org/povray.general/thread/%3Cweb.59d95c8e31ae2f125cafe28e0@news.povray.org%3E//povray.general/thread
/%3C59d9670e@news.povray.org%3E/
"In using functions we use our VM which already pre-calculates everything
it can. In other words in using functions we take the parsing /
re-parsing / re-calculating which happens with macros and turn it into
VM 'compiled' code which can be called."
So POV-Ray has its own little virtual machine for such compiling tasks.
Fascinating.
Using my image_map example again (because images are generally
parse-time-intensive), does this VM/compile idiom still work when turning an
image into a function? Not that it's a practical scheme in most cases, but just
as a clarification of the idea. Like...
pigment {
image_map {
function 500,500 {
pigment {image_map{png "MY_IMAGE.png} }
}
}
}
Post a reply to this message
|
|