% Interface to Lua call:
\startluacode
-- Define namespace as test
test = test or {}
test.luafunc = function (argument)
	return "RETURN: " .. argument
end
test.Upper = function(s)
	return s and string.upper(s) or ""
end
\stopluacode
\def\LuaFunc#1{\directlua{tex.print(test.luafunc("#1"))}}
\def\ChangeUpper#1{\directlua{tex.print(test.Upper("#1"))}}
\starttext
{\bf Lua and interface code:}
\starttyping
\startluacode
-- Define namespace as test
test = test or {}
test.luafunc = function (argument)
	return "RETURN: " .. argument
end
test.Upper = function(s)
	return s and string.upper(s) or ""
end
\stopluacode
\def\LuaFunc#1{\directlua{tex.print(test.luafunc("#1"))}}
\def\ChangeUpper#1{\directlua{tex.print(test.Upper("#1"))}}
\def\textex{textex}
\stoptyping
Test of various macros as input argument to Lua functions.\blank
contextversion = \contextversion\blank
\def\textex{textex}

This call didnt crash:
\type{\LuaFunc{\textex}} = \LuaFunc{\textex}\blank

This call didnt crash:
\type{\ChangeUpper{\textex}} = \ChangeUpper{\textex}\blank

This call didnt crash:
\type{\LuaFunc{\ChangeUpper{\textex}}} = \LuaFunc{\ChangeUpper{\textex}}\blank

\type{\currentdate} = \currentdate\crlf
This call didnt crash:
\type{\WORD{\currentdate}} = \WORD{\currentdate}\blank

This call crashed: \type{\LuaFunc{\currentdate}} =\crlf
%\LuaFunc{\currentdate}

This call too: \type{\expanded{\LuaFunc{\currentdate}}} =
%\expanded{\LuaFunc{\currentdate}}
\starttyping
lua error       > lua error on line 54 in file ./currentdate.tex:
token call, syntax: [ctxlua]:1: invalid escape sequence near '"\c'
\stoptyping

Why is "\currentdate" not transferred to the Lua end, even if \type{\expanded} is applied?
\stoptext

