POV-Ray : Newsgroups : povray.general : Script language speed : Re: Script language speed Server Time
7 Aug 2024 13:15:17 EDT (-0400)
  Re: Script language speed  
From: Redbeard
Date: 7 Nov 2001 11:00:34
Message: <3be95aa2@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:3be91b7f@news.povray.org...
> Redbeard <red### [at] wvadelphianet> wrote:
> : A good way is to parse an included file and keep the parsed file in memory
for
> : the entire execution.
>
>   This might introduce some problems with self-modifying code. Of course it
> shouldn't be a big loss to disallow this (most programming languages do).
>
Self modifying code could be allowed relatively simply, I think.  If the date of
a file has changed between includes, POV-Ray should re-parse it.  Then, of
course, if variables, macros, etc. get changed, the interpreter calls the new
ones.

>   I also wonder if a pov-file including itself may cause some problem (yes,
> this IS possible without creating an infinite include loop). Of course this
> is also a trick not really necessary to be supported.
>
Should work similar to what I mentioned above.  There might be some logistical
problems, but what an include file does when it includes itself is to reparse
itself.  If the file hasn't been changed, the interpreter could just start from
the beginning of the file again.

For some reason, this has got me thinking about namespaces.  Namespaces, for
those who don't know, are ways of segregating variables between sets of files.
Say I write a set of include files that need to use global variables.  Right
now, I have to be careful about naming my globals so no one else tries to use
them.  With namespaces this is somewhat alleviated.  At the top of the file you
add something like "#namespace MDJ" and every global variable referred to in
that file is prefixed with "MDJ::" (this is similar to C++ syntax... the actual
syntax probably would differ).  Within the file I could use the variable "I"
without worrying about it being used outside the file, because it would actually
be "MDJ::I".  Outside the group of files the variable could still be accessed
with "MDJ::I" but that wouldn't be as likely.  I believe other languages use
similar concepts under different names.  Packages are used (I can't remember
what language that is from...) as well as any number of different ways of
distinguising variables from one set of files to another.

What that long-winded paragraph boils down to is that there should be some
consideration made for "macro packages," sets of include files that are
associated with each other but not other include files.  At this point I don't
know how it should be implemented, but I believe it should be discussed.

Well... enough jabbering from me for now.

Michael

--
camera{location<8,20>look_at<6,0,4>}light_source{<8,8>rgb 1}difference{union{
#macro M(D,J)#local R=asc(substr(D,J,1))-32;<div(R,10)*2,mod(R,10)>#end#macro
E(D,B,R)prism{-D,4+D,R#local C=1;#while(C<R+1)M(B,C)#local C=C+1;#end}#end E(
0," (2:FPKAD80* U_dZU"18)sphere{2,2}#macro T(N)cylinder{<9,-N,3><9,4+N,3>3-N}
#end T(0)}T(2)E(1"45LNXUK4"8)pigment{rgb x+y/2}}//(c)2001 MDJohnson(Redbeard)


Post a reply to this message

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