Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaring local variables #411

Closed
EvanAad opened this issue Oct 18, 2017 · 0 comments
Closed

Declaring local variables #411

EvanAad opened this issue Oct 18, 2017 · 0 comments
Labels
enhancement New feature or request

Comments

@EvanAad
Copy link
Contributor

EvanAad commented Oct 18, 2017

The document The expl3 package and LaTeX3 programming (v. 2017/09/18) states on p. 7:

The LaTeX3 coding convention is that all variables must be declared before use.

Similarly, the document The LaTeX3 Interfaces (v. 2017/09/18) states on p. 10:

... 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.

@wspr wspr closed this as completed Oct 18, 2017
@latex3 latex3 locked and limited conversation to collaborators Oct 18, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from wspr Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@latex3 latex3 deleted a comment from EvanAad Oct 19, 2017
@josephwright josephwright added expl3 enhancement New feature or request labels Sep 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants