I'm trying to debug some \newcommand macros I'm working on, and I've got it down to this minimal example. All it does is define two lengths and then set their values - it doesn't use them for anything.
\documentclass{article}
\newlength{\xscale}
\newlength{\yscale}
\newcommand{\setscale}[2] {
\setlength{\xscale}{#1}
\setlength{\yscale}{#2}
}
\newcommand{\mystyle} {
\setscale{0.25cm}{0.18cm}
}
\begin{document}
foo, \mystyle%
bar
foo, \setlength{\xscale}{0.25cm}\setlength{\yscale}{0.18cm}%
bar
\end{document}
The output looks like this:
Why is that large space being inserted when I wrap the \setlength commands inside \newcommand, but not when I don't? How can I define these commands so that they will set the lengths without inserting extra space into the document?

\Ydo?" question. The answer to both questions might be "escape the newlines", but the questions are completely different, and there is no way someone with my question could have know to look up the supposed duplicate. – N. Virgo May 19 '20 at 12:05\setlengthwas the cause of the issue. How could I have known it wasn't? (Other than by a lucky guess, which is what actually happened just after I posted the question.) – N. Virgo May 19 '20 at 12:30%-question. – campa May 19 '20 at 12:49%question comes across a little bit as saying "you should have known what the issue was". It's not really a big deal though. – N. Virgo May 19 '20 at 12:51\bgrouois ignored but none of the braces in the code here can be replaced by\bgroup\egroup. – David Carlisle May 19 '20 at 15:30{}tokens not grouping commands. The{}do not form groups in these contexts. – David Carlisle May 20 '20 at 00:57