![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Wed, 3 Apr 2002 12:36:22 -0600, "Shay" <sah### [at] simcoparts com> wrote:
> > Perhaps this is an intended feature.
>
> yep!
> (docs) 6.2.8.5 Returning Values Via Parameters
> Sorry for the waste of time.
I'm not so sure it was wasting. Note 6.2.8.5 shows only #declare as example. In
6.2.2.2 there is a general rule described (or at least it is my interpretation)
that #local not influences identifiers outside of macro.
ABX
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
wrote:
> I'm not so sure it was wasting. Note 6.2.8.5 shows only #declare as example. In
> 6.2.2.2 there is a general rule described (or at least it is my interpretation)
> that #local not influences identifiers outside of macro.
Moreover this identifier is a local becouse I can undefine it. Undefining causes
remove of value so why this value appear outside ?
#macro Do(A)
#local A=concat(A,"S");
#undef A
#end
#declare C="A";
Do(C)
#warning C
If such (imo strange) behaviour is part of design I think it should be better
documented.
ABX
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Shay <sah### [at] simcoparts com> wrote:
> #macro Persistence_Of_Dimension (ARRAY)
> #local Array_Size = dimension_size (ARRAY, 1) + 1;
> #local ARRAY = array[Array_Size]
> #write (Test_Out, Array_Size, "\n")
> #end // #macro Persistence_Of_Dimension (ARRAY)
You are modifyind the size of the array given as parameter.
That's the designed behaviour. (Note that I used the word "designed",
not "correct".)
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> I'm not so sure it was wasting. Note 6.2.8.5 shows only #declare as example. In
> 6.2.2.2 there is a general rule described (or at least it is my interpretation)
> that #local not influences identifiers outside of macro.
But you are modifying the external identifier with the #local command
because you are modifying the given parameter.
The paramters to a macro are passed by reference, not by value.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 3 Apr 2002 14:32:40 -0500, Warp <war### [at] tag povray org> wrote:
> The paramters to a macro are passed by reference, not by value.
I said it at first post in this thread. Hovewer this could be described somehow
in documentation.
ABX
--
disc{z,-z#macro O()asc(substr("-+((1*(,1,/.-,*/(,&.323/'1"e,1))*.1-4#declare
e=e-1;#end#local e=26;5pigment{#local g=function(_){ceil(_)-_}function#local
k=function{pattern{object{sphere_sweep{linear_spline 13#while(e)<O(),O()//35
>.01#end}}}}{k(g(atan2(x,y)),g(ln((y+x)^2+1e-5)),0)}}finish{ambient 1}}//ABX
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
From: Tom Melly
Subject: Re: Is this a bug, or am I missing something?
Date: 4 Apr 2002 07:51:20
Message: <3cac4c48@news.povray.org>
|
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
news:uemmauca47t09qc6u28rjptcm9b745d84p@4ax.com...
> On 3 Apr 2002 14:32:40 -0500, Warp <war### [at] tag povray org> wrote:
> > The paramters to a macro are passed by reference, not by value.
>
> I said it at first post in this thread. Hovewer this could be described
somehow
> in documentation.
>
Wow - I never knew that. Might explain a lot.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
From: Ben Chambers
Subject: Re: Is this a bug, or am I missing something?
Date: 4 Apr 2002 12:38:18
Message: <3cac8f8a@news.povray.org>
|
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
news:tgemaugb05ng3mdc4i9801ihtlrrc4ogr3@4ax.com...
> On Wed, 3 Apr 2002 11:13:42 -0600, "Shay" <sah### [at] simcoparts com> wrote:
> > I will post this in bug-reports if it turns out to be a bug, but I often
> > miss obvious things when looking at my own code.
>
> I was noticed similiar thing just yesterday and wondered what to do with
that.
> Looks like #local works as #declare for references (instead of value) as
> parameter. For example
Doesn't #local limit the scope to the file, and not the macro? Or did I
misunderstand?
...Chambers
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.323 / Virus Database: 180 - Release Date: 2/8/2002
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Thu, 4 Apr 2002 09:38:36 -0800, "Ben Chambers" <bdc### [at] yahoo com>
wrote:
> Doesn't #local limit the scope to the file, and not the macro? Or did I
> misunderstand?
http://www.povray.org/working-docs/id000147.html#6_2_2_2
ABX
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 3 Apr 2002 14:32:40 -0500, Warp wrote:
> The paramters to a macro are passed by reference, not by value.
That's not entirely true.
#macro F(A)
...
#end
#declare B=5;
F(B) // passes by reference
F(5) // passes by value
The difference is precisely this: if the macro invocation uses an indentifier,
it is passed by reference. If it uses an expression or object {} block or
something else, it is passed by value (well, not exactly, but let's pretend.)
Parameter names are local to the macro. They are defined in the macro
invocation's local symbol table and are thus local. When the tokenizer
sees a parameter that also happens to be a reference, it replaces it
directly by the symbol to which it refers in some higher-level symbol
table (not necessarily the global symbol table.) However, since it found
the original reference in the local symbol table, #local does not try to
create a new variable.
You could argue either way as to how this should work. Personally, I think
I'd be in favor of #local severing the 'reference' link, but that would
require a bit of nasty code in some unlikely places.
--
#local R=rgb 99;#local P=R-R;#local F=pigment{gradient x}box{0,1pigment{gradient
y pigment_map{[.5F pigment_map{[.3R][.3F color_map{[.15red 99][.15P]}rotate z*45
translate x]}]#local H=pigment{gradient y color_map{[.5P][.5R]}scale 1/3}[.5F
pigment_map{[.3R][.3H][.7H][.7R]}]}}}camera{location.5-3*z}//only my opinions
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <slr### [at] fwi com>,
Ron Parker <ron### [at] povray org> wrote:
> You could argue either way as to how this should work. Personally, I think
> I'd be in favor of #local severing the 'reference' link, but that would
> require a bit of nasty code in some unlikely places.
I'd like it if there were separate keywords for making new variables and
modifying old ones:
#local always creates a local variable. If one with the same name
exists, it is destroyed and replaced. The original variable of a
parameter passed by reference will be untouched.
#declare creates a global variable, otherwise same rules as above. Maybe
change name to #global.
Add a new #set directive for modifying existing variables. If the
variable doesn't already exist, an error results. This would also avoid
situations like:
#local MyCounter = 0;
#while(MyCounter < 10)
...
#local myCounter = MyCounter + 1;
#end
Oops...a little typo makes an infinite loop. With #set:
#local MyCounter = 0;
#while(MyCounter < 10)
...
#set myCounter = MyCounter + 1;
#end
You get something like:
Error: attempt to #set non-existent variable "myCounter"
The #set directive is already partially implemented as a patch, though
it doesn't work perfectly yet. To do all of this would probably require
reworking large chunks of the parser, probably better to just start over
from scratch.
--
Christopher James Huff <chr### [at] mac com>
POV-Ray TAG e-mail: chr### [at] tag povray org
TAG web site: http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |