POV-Ray : Newsgroups : povray.general : Problem with parameters : Re: Problem with parameters Server Time
31 Jul 2024 00:31:29 EDT (-0400)
  Re: Problem with parameters  
From: Tor Olav Kristensen
Date: 27 Feb 2008 02:51:32
Message: <47c51684$1@news.povray.org>
Tim Attwood wrote:
>>> #macro DoCalc(pZ,pY,I,N) //function arbitrarily choosen
>>>   #local pY= y*cA*sin(2*pi*cFr*I/N+cFs);
>>>   #local pZ= z*L*I/N;
>>> #end
>> ...
>>
>> Note that this macro should (AFAIK) have no effect in any scene.
>>
>> If it has, then that might be a bug in the POV-Ray version you
>> are using.
>>
>> (You are just setting 2 local variables that are "lost" right
>> afterwards when the macro is exited.)
> 
> That isn't exactly right, pY and pZ are being returned by
> parameter.

How can it be wrong when his macro is not returning anything ?
(Note that he is using #local instead of #declare.)

I have re-read these to sections of the documentation;

   "2.2.2.2 The #declare and #local Directives"
   "2.2.2.8 User Defined Macros"

- without finding anything that about changing contents of
passed parameters within macros by using #local.

The 2 manual sections:

   http://www.povray.org/documentation/view/3.6.1/237/
   http://www.povray.org/documentation/view/3.6.1/243/

> Unfortunately in 3.6 passing values by parameter is buggy,
> it's fixed in the 3.7 beta, but in general you probably shouldn't
> rely on values being returned correctly via parameter.
...

Yes I know. Sometimes I have to use v3.5 to render my code.
(But I have never been able to make a simple scene file that
clearly demonstrates the problem.)

-- 
Tor Olav
http://subcube.com


Post a reply to this message

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