Page 1 of 1

Bug: pre-processor not respecting for loop scope.

PostPosted: Thu May 20, 2010 1:57 pm
by cfp
This is not a critical bug, but fixing it would help prevent people (e.g. me) shooting themselves in the foot.

If you have a pre-processor loop, for example:

Code: Select all
@#for lead in 1:offset
      LEAD@{lead}_FrakturIPart(0) = LEAD@{lead-1}_FrakturIPart(+1);
@#endfor


Then upon hitting the
Code: Select all
@#endfor
statement, the pre-processor variable
Code: Select all
lead
should ceased to be defined.

When copying and pasting code around it's very easy to accidentally end up with loop local variables that shouldn't be there. Throwing an error in this circumstance would be a great help.

Tom

Re: Bug: pre-processor not respecting for loop scope.

PostPosted: Mon May 24, 2010 9:17 am
by SĂ©bastienVillemot
Hi,

This is not really a bug but a characteristic of the macro-language. This behavior is normal because all the macro-variables have global scope. There is no concept of local scope in the macro-language. Maybe we should make that more explicit in the documentation. And changing this behavior wouldn’t be easy. for implementation and backward compatibility reasons.

Best,