POV-Ray : Newsgroups : povray.text.tutorials : #declare vs. #local Mojo : Re: #declare vs. #local Mojo Server Time
5 Oct 2024 15:10:17 EDT (-0400)
  Re: #declare vs. #local Mojo  
From: Le Forgeron
Date: 25 Jun 2015 02:09:11
Message: <558b9b07$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Le 25/06/2015 02:26, clipka a écrit :
> Some fun(?) fact to know:
> 
> If, in an include file or macro, you use #declare with an
> identifier that already happens to exist at a non-global scope, you
> will NOT change the corresponding global variable, but the most
> local variable of that name.
> 
> Expected that? I didn't.

I did, but I know how the context are stacked...

My hint: do not mix #declare and #local for the same variable, or even
parameter name of macro.

The same kind of problem happens with other languages, it's called
shadowing and it's a mess to know which one is used.

The long way would be to issue warning when using #local on a
#declare/d variable, and vice-versa, but it might requires extending
each storage to store that piece of data ( there is also #for... the
variable is kind of #local, yet should it be allowed to be updated
with #local ? )


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iJwEAQEIAAYFAlWLmwcACgkQhKAm8mTpkW32VQQA033DeqL81d9BI1pJi1x36162
CLTu8rPTzYZa0FbOTuCF+QtyqNOiVtsyx5qGjopK3UKLzvw/ss/ZLErbVmlvGD6Q
Mq7WwXAedgrFP0hTtTrUJV09Bgh98O35+SdHq7fGjcoF2eizjI41oSalzzknPePO
oi8stAyB3RcXzHx2SFY=
=l9L2
-----END PGP SIGNATURE-----


Post a reply to this message

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