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
... in contrast to variables, which must always be declared
expl3 provides no facilities to declare a variable locally; only globally. However, it is still possible to create a local variable implicitly using the various \..._set:N... functions.
It is a principle of structured programming that dumping variables into the global scope unnecessarily should be avoided. The TeX language, like all high-level programming languages that I know (including C, C#, Fortran, Java, Lisp, Pascal, and Python), provides a scoping construct for creating local variables, namely groups. Moreover, the LaTeX3 programming language itself, thankfully, supports the creation of local variables, despite what the manuals suggest.
In my opinion, the admonitions quoted above should be deleted from the manuals, and it should be explained that variables can, and should, be created locally whenever possible.
Moreover, if it is indeed desired to encourage a programming style in which all variables are declared before they are used (I personally think this is a matter of programming style that should be left to the individual taste of the programmer), functions need to be provided for declaring local variables just as there are functions for declaring global variables.
The text was updated successfully, but these errors were encountered:
The document The expl3 package and LaTeX3 programming (v. 2017/09/18) states on p. 7:
Similarly, the document The LaTeX3 Interfaces (v. 2017/09/18) states on p. 10:
expl3
provides no facilities to declare a variable locally; only globally. However, it is still possible to create a local variable implicitly using the various\..._set:N...
functions.It is a principle of structured programming that dumping variables into the global scope unnecessarily should be avoided. The TeX language, like all high-level programming languages that I know (including C, C#, Fortran, Java, Lisp, Pascal, and Python), provides a scoping construct for creating local variables, namely groups. Moreover, the LaTeX3 programming language itself, thankfully, supports the creation of local variables, despite what the manuals suggest.
In my opinion, the admonitions quoted above should be deleted from the manuals, and it should be explained that variables can, and should, be created locally whenever possible.
Moreover, if it is indeed desired to encourage a programming style in which all variables are declared before they are used (I personally think this is a matter of programming style that should be left to the individual taste of the programmer), functions need to be provided for declaring local variables just as there are functions for declaring global variables.
The text was updated successfully, but these errors were encountered: