# Why \newlength is not profiled as \newcommand?

While commands are defined and set in one step with \newcommand, lengths need two steps for this: \newlength and then \setlength. Because

\newlength{\foo}{1cm}

would be easier than

\newlength{\foo}
\setlength{\foo}{1cm}

I wonder if there is a special reason for \newlength to not have been profiled as \newcommand.

• In general you want to give commands always a definition, while it often happens that you only reserve lengths for later uses. expl3 offers \tl_new:N and \tl_set:Nn for commands. And there is \dim_const:Nn to set a dimension directly (the "const" in the name makes it a bit awkward to use for dimension you want to change later). – Ulrike Fischer Nov 14 '14 at 8:23
• @UlrikeFischer If you do \tl_const:Nn, then the variable should not change its value (across a LaTeX run); similarly for \dim_const:Nn and the other similar functions. Exemplary is \int_const:Nn \c_x_int: you can't even say \int_incr:N \c_x_int. The fact that changing the value of a constant dimension is possible with, say, \dim_add:Nn is just implementation dependent and shouldn't be relied on. – egreg Nov 14 '14 at 9:42
• In my experience, the cases where one allocates a length register and wants to set the value immediately are a small minority. – egreg Nov 14 '14 at 9:45
• @egreg: Yes I wouldn't \dim_const:Nn etc for register I want to change a lot (a \dim_new:Nn would be better to declare and set in one go). Would you use a constant for a value that is changed once? First a default is set and at the begin of the document it is perhaps changed? (An example is the font size of a document). – Ulrike Fischer Nov 14 '14 at 10:04
• @UlrikeFischer Once set, a constant should not change. – egreg Nov 14 '14 at 10:10