POV-Ray : Newsgroups : povray.general : #local access : Re: #local access Server Time
8 Aug 2024 04:08:34 EDT (-0400)
  Re: #local access  
From: Ron Parker
Date: 2 Mar 2001 08:18:51
Message: <slrn99v7ds.vvg.ron.parker@fwi.com>
On Fri, 02 Mar 2001 07:54:16 -0500, Chris Huff wrote:
>In article <3a9edf2f@news.povray.org>, "Rune" <run### [at] inamecom> 
>wrote:
>
>> > 4.) When ASSIGNING A VALUE TO AN EXISTING identifier using #declare,
>> > it assigns it to the most recent, most local version at the time.
>> 
>> I didn't know that! That's great! It solves my problems! Thanks!
>
>This does not seem right...#declare should always create a global 
>variable. It is certainly unintuitive...to me at least.

#declare always CREATES a global variable, but it doesn't always MODIFY one.
That's the way it's always been, and it's documented behavior.  It seems 
intuitive to me: if you use #declare to modify a variable, you're guaranteed
to modify the variable that you would have seen when you interrogated it.
Wouldn't it suck to do it otherwise if you had something like this?

#macro ForceVarInBounds()
  #ifdef(Var)
    #if (Var < 0) #declare Var=0; #end
    #if (Var > 255) #declare Var=255; #end
  #end // ifdef
#end // macro

#macro DoStuff() {
  #local Var=SomeFunction();
  ForceVarInBounds()
  DoSomethingCriticalWithVar()
#end // macro

Oops... The ForceVarInBounds macro didn't do what you thought it would.
Yeah, I know, we shouldn't use global variables.  That being the case, 
this will never be a problem.

>This seems like a cleaner and less confusing system...

It doesn't seem less confusing to me.  If you implement it, I forsee lots of

#ifdef (foo)
  #set foo = SomeComplicatedMacro();
#else
  #declare foo = SomeComplicatedMacro();
#end



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


-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

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