From: Henri Menke via ntg-context <ntg-context@ntg.nl>
To: ntg-context@ntg.nl
Cc: Henri Menke <henri@henrimenke.de>
Subject: Re: protected macro vs protected luacall
Date: Fri, 27 Jan 2023 12:03:28 +0100 [thread overview]
Message-ID: <c48da18a9aa3ba0f43be2d7d4ef4f55baac37d1d.camel@henrimenke.de> (raw)
In-Reply-To: <23eb2bf7-6b9c-1ff5-31fe-6d062f900c63@freedom.nl>
On Fri, 2023-01-27 at 11:01 +0100, Hans Hagen via ntg-context wrote:
> On 1/27/2023 10:35 AM, Henri Menke via ntg-context wrote:
>
> > Thanks, this is indeed the workaround that I currently use.
> > However,
> > the downside is that this has to tokenize the contents of
> > \directlua
> > every time (and is therefore susceptible to surrounding \catcode
> > shenanigans) and it expands in at minimum two steps, whereas a
> > luacall
> > always expands in a single step. But I guess that's what I will
> > have to
> > live with.
> on my 2018 laptop, with
>
> function FoO() end
>
> this
>
> \directlua{FoO()}}
>
> takes 0.0000014 seconds so probably the least of your worries
> compared
> to other macro and lua magic
True, but then there is still the problem with the number of
expansions. With a nested \directlua I always need at least two steps
to get the result from Lua.
\directlua{
function TestCmd()
tex.print("\string\\numexpr 17\string\\relax")
end
lua.get_functions_table()[999] = TestCmd
}
\let\:\expandafter % I'm lazy
\tt
\directlua{token.set_lua("test", 999)}
\:\def\:\x\:{\test}\meaning\x % macro:->\numexpr 17\relax
\protected\def\test{\directlua{TestCmd()}}
\:\def\:\x\:{\test}\meaning\x\par % macro:->\directlua {TestCmd()}
\:\:\:\def\:\:\:\x\:\:\:{\test}\meaning\x % macro:->\numexpr 17\relax
\bye
How much do you think would break if protected luacall were treated
like protected macros after \the in the engine?
That would probably need an extra branch in the switch(cur_cmd) in
scan_something_internal. Currently protected luacall just goes to the
default branch (You can't use ...).
Cheers, Henri
>
> Hans
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
> _____________________________________________________________________
> ______________
> If your question is of interest to others as well, please add an
> entry to the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : https://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> _____________________________________________________________________
> ______________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2023-01-27 11:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 20:33 Henri Menke via ntg-context
2023-01-26 22:07 ` Hans Hagen via ntg-context
2023-01-27 9:13 ` Henri Menke via ntg-context
2023-01-27 9:30 ` Hans Hagen via ntg-context
2023-01-27 9:35 ` Henri Menke via ntg-context
2023-01-27 10:01 ` Hans Hagen via ntg-context
2023-01-27 11:03 ` Henri Menke via ntg-context [this message]
2023-01-27 11:52 ` Hans Hagen via ntg-context
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=c48da18a9aa3ba0f43be2d7d4ef4f55baac37d1d.camel@henrimenke.de \
--to=ntg-context@ntg.nl \
--cc=henri@henrimenke.de \
/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).