LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Johannes Burtscher <[log in to unmask]>
Tue, 2 Oct 2018 15:46:10 +0200
text/plain (20 lines)
Hi all,

since TeX is actually a macro processor, I find it somewhat difficult to convert concepts from other languages to it. Currently I'm wondering about the following: let's say I have a function that takes some input, processes it and then hands the results off to some auxiliary functions. These functions exist solely to keep things reasonably organized and are never called by any other function. The question now is: should these auxiliary functions take their input as actual arguments or should they simply rely on the variables set up by the caller?

    \seq_new:N \l__jfa_my_seq
    \cs_new_protected:Nn \__jfa_func:n
        \seq_set_split:Nnn \l__jfa_my_seq {/} {#1}
        \__jfa_func_aux:N \l__jfa_my_seq
    \cs_new_protected:Nn \__jfa_func_aux:N
      { \seq_show:N #1 }
    \cs_new_protected:Nn \__jfa_func_aux:
      { \seq_show:N \l__jfa_my_seq }

In any other language I would clearly opt for the explicit argument just to avoid global variables but with TeX's scoping rules the situation seems to be fundamentally different. I (think I) know that it doesn't make any difference after all, but I would still like to know if one variant is preferred over the other and, if so, why.