From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: LMTX MkIV difference in expansion
Date: Sat, 21 Nov 2020 16:05:47 +0100 [thread overview]
Message-ID: <8c0905ee-8c0f-02f8-cc46-e9712afb137e@gmail.com> (raw)
In-Reply-To: <cb80e224-de97-b972-ca40-f1445ae5d598@rik.users.panix.com>
Rik Kabel schrieb am 20.11.2020 um 00:18:
> You are right about not quite understand.
There are cases where you want to pass a command to another command as
it is without replacing it with its content, e.g. when you store the
\TeX logo in the table of content the \TeX command should be written in
the register and not the content of the command.
In the following example the first line prints the definition of the
\TeX logo but in many cases you ant to preserve the command as in the
second line.
\starttext
\tex{TeX} = \detokenize\expandafter{\TeX}
\blank
\tex{TeX} = \detokenize{\TeX}
\stoptext
To make it easier to keep the command eTeX added a new command
\protected which can be used before \def to achieve this (ConTeXt
provides the same thing under the name \unexpanded).
The following example shows how you can use \protected\def to keep
always the current meaning of \foo when you print the content of \bar.
\starttext
\def\foo{foo}
\edef\bar{\foo}
\def\foo{bar}
\startlines
bar=\bar
foo=\foo
\stoplines
\blank
\protected\def\foo{foo}
\edef\bar{\foo}
\protected\def\foo{bar}
\startlines
bar=\bar
foo=\foo
\stoplines
\stoptext
A problem in older TeX engines is that \csname ...\endcsname didn't
respect this protection and replaced the protected command with its
content, recently Hans changed this behavior in LMTX which lead to the
error message in your document.
> Does this mean that I can have the same definitions in MkIV and LMTX
> (after some future update), or should I hunt down the \defines in both,
> or that I should fork (or mode test) my source environment files, one
> set for LMTX and one for MkIV?
When you use \define to store arguments which are passed as arguments to
other command you have to change this to \defineexpandable but its best
to do this in MkIV and LMTX because protected commands are the wrong
thing in this case. Even though it would work in MkIV in some cases you
run into problems when you pass argument to Lua.
Wolfgang
___________________________________________________________________________________
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 prev parent reply other threads:[~2020-11-21 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 20:20 Rik Kabel
2020-11-19 20:41 ` Wolfgang Schuster
2020-11-19 22:03 ` Hans Hagen
2020-11-19 23:18 ` Rik Kabel
2020-11-20 7:53 ` Hans Hagen
2020-11-21 15:05 ` Wolfgang Schuster [this message]
2020-11-21 15:25 ` Rik Kabel
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=8c0905ee-8c0f-02f8-cc46-e9712afb137e@gmail.com \
--to=wolfgang.schuster.lists@gmail.com \
--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).