POV-Ray : Newsgroups : povray.general : Request for enhancement Server Time
8 Aug 2024 18:21:31 EDT (-0400)
  Request for enhancement (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Chris Huff
Subject: Re: Request for enhancement
Date: 4 Dec 2000 16:15:51
Message: <chrishuff-163A13.16163404122000@news.povray.org>
In article <3A2BA6E1.8E54FEF4@pacbell.net>, lin### [at] povrayorg 
wrote:

> Careful ! Everytime I think something is impossible to do with
> POV-Ray Mr. Colefax or Mr. Parker comes along and show just how
> possible it really is :)

Well, this *is* impossible without modifying the source, because there 
is no way to declare a #local variable for use in a macro calling a 
macro...

This macro:

#macro assignLocal(Var, Value) #local Var = Value; #end

will not do the job correctly, it will just define a variable that is 
local to the assignLocal macro.
Actually, #declare, as used in the original macro, *might* work, if 
there is a specific side-effect of the way POV handles modifying of 
parameters...if "#declare ParamName" doesn't do what "#declare VarName" 
does. I don't know if this side-effect exists, or even if it would be a 
bug or feature...something to try and see.

BTW, another problem with that assign() macro: it uses a semicolon, 
which will prevent you from using objects, textures, etc...you could 
remove that semicolon:
#macro assign(Var, Value) #declare Var = Value #end
but this will produce a warning whenever you use it with a vector, 
color, or float, which can slow parsing down and may not work at all in 
future versions(semicolons really should be used, or at least allowed, 
for all variable declarations!).

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Chris Colefax
Subject: Re: Request for enhancement
Date: 4 Dec 2000 18:35:37
Message: <3a2c2a49@news.povray.org>
Chris Huff <chr### [at] maccom> wrote:
> Because you can't do this with macros? :-)
> The #set directive works with both #declare and #local, and will be
> faster than calling a macro, not to mention looking better in the scene
> code...

#macro Macro()
   #local X = 6;
   #debug concat("X = ", str(X, 0, -1), "\n")

   assign (X, 5);
   #debug concat("X = ", str(X, 0, -1), "\n")
#end

#macro assign (Var, Value) #declare Var = Value #end

#declare X = 1;
#debug concat("X = ", str(X, 0, -1), "\n")

assign (X, 3);
#debug concat("X = ", str(X, 0, -1), "\n")

Macro()

#debug concat("X = ", str(X, 0, -1), "\n")

As expected, this returns X-values of 1 (declared), 3 (assigned), 6
(localed), 5 (assigned to local), and 3 again (globally assigned).  This
seems to work pretty well to me!  And it works fine with objects and other
variable types, and looks quite neat.  Speed shouldn't be a major issue, as
Bob seemed to want the function mostly as a debugging tool.  For final
distributable code, the assign's could easily be changed to #declare
statements.

It's not that I don't think POV-patches have their value - simply that one
of the real strengths of POV is its portability and accessibility, and doing
as much as possible to maintain this seems, to me at least,  preferable to
splintering POV-users into different groups based on
platforms/versions/whatever.


Post a reply to this message

From: Warp
Subject: Re: Request for enhancement
Date: 5 Dec 2000 05:48:32
Message: <3a2cc7ff@news.povray.org>
Chris Huff <chr### [at] maccom> wrote:
: Well, this *is* impossible without modifying the source

  You should believe Ken... As always :)

  Check this:

#macro assignLocal(Var)
  #local Var
#end

#declare ABC=1;

#macro TestLocal()
  #local ABC=2;
  assignLocal(ABC) = 5;
  #debug concat("Local 'ABC': ", str(ABC,0,0), "\n")
#end

TestLocal()
#debug concat("Global 'ABC': ", str(ABC,0,0), "\n")



: BTW, another problem with that assign() macro: it uses a semicolon, 
: which will prevent you from using objects, textures, etc...

  That solution I present above also solves the semicolon problem.

-- 
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

From: =Bob=
Subject: Re: Request for enhancement
Date: 6 Dec 2000 00:14:49
Message: <3a2dcb49$1@news.povray.org>
Thanks everybody, and this last one did everything I
needed. The code doesn't look too bad either.
Of course, I still want a built-in version :^)

=Bob=

"Warp" <war### [at] tagpovrayorg> wrote in message
news:3a2cc7ff@news.povray.org...
[Deletions]


:   That solution I present above also solves the semicolon problem.
: 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

<<< Previous 10 Messages Goto Initial 10 Messages

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