From: Hans van der Meer <havdmeer@ziggo.nl>
To: NTG ConTeXt <ntg-context@ntg.nl>
Subject: explain please
Date: Wed, 24 Jun 2020 21:00:25 +0200 [thread overview]
Message-ID: <12562968-F8D1-4744-803C-1C9184818D94@ziggo.nl> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 204 bytes --]
How can the crash in the minimal example here be explained? And is there a solution to avoid this and make the crash going away "without having to jump through special hoops"?
dr. Hans van der Meer
[-- Attachment #1.2.1: Type: text/html, Size: 1309 bytes --]
[-- Attachment #1.2.2: currentdate.pdf --]
[-- Type: application/pdf, Size: 18767 bytes --]
[-- Attachment #1.2.3: Type: text/html, Size: 208 bytes --]
[-- Attachment #1.2.4: currentdate.tex --]
[-- Type: application/octet-stream, Size: 1703 bytes --]
% 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
[-- Attachment #1.2.5: Type: text/html, Size: 226 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next reply other threads:[~2020-06-24 19:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 19:00 Hans van der Meer [this message]
2020-06-24 19:10 ` Hans Hagen
2020-06-24 19:31 ` Hans van der Meer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12562968-F8D1-4744-803C-1C9184818D94@ziggo.nl \
--to=havdmeer@ziggo.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).