On 8/19/14, Stephan Hennig <[log in to unmask]> wrote: > Am 19.08.2014 um 19:21 schrieb Heiko Oberdiek: > >>> \ExplSyntaxOn >>> \directlua{ >>> local myarg = '\mymacro' >>> texio.write_nl('l3: argument is ' .. tostring(myarg)) >>> } >>> [...] >>> First, spaces are gone in Lua code. Though, spaces are significant in >>> Lua. >> >> `\ExplSyntaxOn' says that spaces are gone, that's the purpose of this >> command. Explicit spaces are available via `~': > > Have already seen that when using l3's message mechanism, but didn't try > in \directlua. Thanks! > > >>> Second, variable myarg is nil with \ExplSyntaxOn. (I don't understand >>> why.) >> >> Without spaces you get: >> >> localmyarg='\mymacro' > > Should have seen that by myself. Thanks again! > > >> BTW, this is quite a risky way to pass the contents of user variables ot >> Lua code. Consider syntax errors, if "\mymacro" contains ', or >> "\mymacro" could even contain containing something like: >> '; very evil code; local dummy=' >> >> There is \luaescapestring/\luatexluaescapestring: >> >> '\luatexluaescapestring{\mymacro}' > > It's actually a language string that I'm evaluating to a number via > > \the\csname l@#1\endcsname or > \int_use:N\cs:w l@#1\cs_end: in LaTeX3 > > If #1 contains no valid language identifier, the expression should throw > an error. So, I think I'm safe here. I'm indeed using \luaescapestring > in other circumstances. > > Thanks! > Stephan Hennig Avoid using \cs:w ... \cs_end: constructions. It is much better to use a c-type argument, so for your case, \int_use:c { l@#1 }. Regards, Bruno