|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
-----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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
clipka <ano### [at] anonymousorg> wrote:
> 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.
Expected? No.
Knew? Yes.
The problem with this odd behavior is that it is actively being used. Or used to
be at least.
Thorsten
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 25.06.2015 um 08:09 schrieb Le_Forgeron:
> ( there is also #for... the
> variable is kind of #local, yet should it be allowed to be updated
> with #local ? )
Mucking around with the variable in a #for statement isn't really what
I'd call best practice, but if you need to change the value, then #local
should be the thing to use.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
clipka <ano### [at] anonymousorg> wrote:
> 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.
http://wiki.povray.org/content/Reference:Declare_and_Local_Directives#Identifier_Name_Collisions
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |