You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interesting case. Semantically, the code you wrote does not mean what you intended. Instead, IF means: if the condition is true, then include its code block in the compilation. By design, DEF does not belong into the code block, because it is evaluated at compile time, not included at compile time. DEF is a compile time thing and not controlled by conditions itself. Meaning, both DEF assignments are being evaluated, in code order, and the last one survives and goes into the execution of the print().
Now, the fix could go either way: either implement a control flow for DEF inside of conditionals, or disallow indented DEFs. I'm slightly leaning towards the latter since it's not really clear to me that the first is a feature worth having. These compile time expressions have a tendency to be generally overused...
Thanks for your response. I see the difference now. However it seems the documentation here is not giving this detail. I am quoting
An IF statement can appear anywhere that a normal statement or declaration can appear, and it can contain any statements or declarations that would be valid in that context, including DEF statements and other IF statements.
I am actually using this for early-binding. User at compile time can set which classes to be compiled.