From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113424 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wolfgang Schuster via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: directsetup vs setups Date: Mon, 15 Nov 2021 23:48:16 +0100 Message-ID: <579cc968-4bfd-8024-7c41-117318f79f00@gmail.com> References: <9314580b-537f-a406-0bab-4db53c71d8bf@rik.users.panix.com> <9ca345bf-bcb7-0e13-262e-830563326384@panix.com> <2bcacade-324c-26c1-16cf-293168c8ca3f@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3372364702775196431==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27813"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.51 Cc: Wolfgang Schuster , mailing list for ConTeXt users To: Rik Kabel Original-X-From: ntg-context-bounces@ntg.nl Mon Nov 15 23:48:51 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmkmR-00075c-LC for gctc-ntg-context-518@m.gmane-mx.org; Mon, 15 Nov 2021 23:48:51 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 647B7289274; Mon, 15 Nov 2021 23:48:22 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k0R8nQr-z1GF; Mon, 15 Nov 2021 23:48:20 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 90D6528936B; Mon, 15 Nov 2021 23:48:20 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8DD47289340 for ; Mon, 15 Nov 2021 23:48:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QK8FODEf22r1 for ; Mon, 15 Nov 2021 23:48:18 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.42; helo=mail-wr1-f42.google.com; envelope-from=wolfgang.schuster.lists@gmail.com; receiver= Original-Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 1C01D289274 for ; Mon, 15 Nov 2021 23:48:18 +0100 (CET) Original-Received: by mail-wr1-f42.google.com with SMTP id t30so33614594wra.10 for ; Mon, 15 Nov 2021 14:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=KHU1Vz1/TBSiycybKb8q9Khd3iF8Nn/yJuBf2G9YJU0=; b=pZmD7EL+R3mtJLTTlT6NHuJMOrDRrOiMJgyE5pWM9mapLEENhVwp9bUuCYlVZTRkGF qt7TtqhVJiTyOYIbHN+W9TvGqj5giauXi+yPynUZEyZSkG6EuIrJ/OhbU2OYE5BesYd/ to8f8qacuYCkLcFKM/Dgpfzw4m8AZ7czLiPZ0JrkAm+BNvY86iSeSYFL7nuJaW8qvv+G 1B/YwUL3eYH4fqOMVSF8EDuC4CyWMcb5/LSgXsIvmBZR7h6YP73xoLV1Tb/mb26niWM/ l2cS7KKJurb2sX/+hxMrTbj/eEn8s85YpvjI6G1SGgT4bA+tsCRo5APQJJyF6WAzf2Ht CFcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=KHU1Vz1/TBSiycybKb8q9Khd3iF8Nn/yJuBf2G9YJU0=; b=eEfMlu0FG2W62N0L26KeXiCKCVharkH1uEPX9DKNtoUM7a2wmqU+b1r2AZzoUsy1AV MzGdVkbIpHNgIsTTBofjaVDhbP7TSGomy34GDD+KPyYPLUM6Ikueee0Cnnj+gCJhetgG ihK84XqVYxzlwkXQtgp+AcfalQzlSVO8K0LtvQadJOOB0oGq4jQsi0xSG0E7PdQ0epAq jXPrSkGL7Qnugw9lH0/Wme1lxFp2wbAbqKvgDsXt/ELokCtW7CZvcE1MAYotm56/PfgM ZkEWL2YrZAVdwqC2lOllNbhNjma4uvu3I8kRMvrUYGPK0akj+RPOmDerNCprJj5wVDDZ wfSw== X-Gm-Message-State: AOAM531vtEQiHu0XwxAR53Ih2r1OIaLVgbttyQ+oDfV2gQvuqA6KrL7n KxojRlEzvzT/+qdogYr50mc8h0QdaaM= X-Google-Smtp-Source: ABdhPJxbLycopkdEHm9FGJcyGPYWnGxiHX7zBuZQWPXBdlzatBDnFEpfrDjRiyh5X63LWUS/MxS9aA== X-Received: by 2002:adf:ce08:: with SMTP id p8mr3270137wrn.154.1637016497637; Mon, 15 Nov 2021 14:48:17 -0800 (PST) Original-Received: from ?IPv6:2a02:810d:a8bf:f874:4581:4215:f65a:89e2? ([2a02:810d:a8bf:f874:4581:4215:f65a:89e2]) by smtp.gmail.com with ESMTPSA id d6sm15501984wrx.60.2021.11.15.14.48.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Nov 2021 14:48:17 -0800 (PST) In-Reply-To: Content-Language: en-US X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:113424 Archived-At: This is a multi-part message in MIME format. --===============3372364702775196431== Content-Type: multipart/alternative; boundary="------------5B4D4359A93FF7DC7A38DD92" Content-Language: en-US This is a multi-part message in MIME format. --------------5B4D4359A93FF7DC7A38DD92 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Rik Kabel schrieb am 15.11.2021 um 22:51: > > Wolfgang, > > Can you expand on the following statements from your reply? > > You can run Hans example with MkIV and the differences should be > even bigger because the check for [] is slower here while in LMTX > it's a engine feature. The main difference in LMTX is a extra > expansion for \setup compared to \directsetup. > > there is no difference between \setup and \directsetup > > Are you saying: > > 1. When [] are used with \setup, expansion of the contents is done > differently than when {} are used. It doesn't matter which form you use for \setup. What I'm trying to say is that \setup is slower (or better was slower in MkIV) than \directsetup because \setup has to check first if the name is passed within brackets or as normal argument in braces. The code in MkIV would look similar to this: \def\setup   {\doifnextcharelse[      \setup_brackets      \setup_braces} \def\setup_brackets[#1]%   {\directsetup{#1}} \def\setup_braces#1%   {\directsetup{#1}} > 2. There is no significant processing time difference between \setup > and \directsetup. > When I run the following example on my machine \starttext \startsetups [dummy] \stopsetups \testfeatureonce{100000}{\setup      {test}} \elapsedtime \par \testfeatureonce{100000}{\directsetup{test}} \elapsedtime \par \stoptext I get these times. # MkIV \setup       : 0.136s \directsetup : 0.079s # LMTX \setup       : 0.083 seconds \directsetup : 0.071 seconds Add additional stuff in the setup environment and the difference between \setup and \directsetup doesn't matter anymore. > 3. There is additional expansion performed for \setup compared to > \directsetup. > Although this isn't completely true (but very close) the definition for \setup in LMTX is like this: \def\setup#1{\directsetup{#1}} > 4. Under LMTX, because {} and [] handling overhead is so similar, the > most visible processing time difference to users is from the > difference in  expansion between \setup and \directsetup. > > I think you are saying that 2, 3, and 4 are true, but that 1 is not true. > > If that is the case, can you provide an example that demonstrates the > difference in expansion between \setup and \directsetup? > > Also, as far as expansion, is \fastsetup like \setup or like \directsetup? > \setup and \directsetup are similar. \fastsetup is like the name implies a faster version which ignores grid mode and doesn't care whether the requested environment even exists. > My simple testing shows no difference between setup, directsetup, and > fastsetup for namespace set and reset. Is it your understanding that > they all behave the same? > No, \fastsetup behaves different because it leaves \relax\empty in the input when you pass the name of a not existing environment. It shouldn't matter in normal usage but below are two examples. Example 1: \starttext \tex{directsetup} \scratchcounter 12\directsetup{unknown_a}34 \the\scratchcounter \tex{fastsetup} \scratchcounter 12\fastsetup{unknown_b}34 \the\scratchcounter \stoptext Example 2: \starttext \normalexpanded{\noexpand\firstoftwoarguments\directsetup{unknown_a}xy} \normalexpanded{\noexpand\firstoftwoarguments\fastsetup{unknown_b}xy} \stoptext Wolfgang --------------5B4D4359A93FF7DC7A38DD92 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Rik Kabel schrieb am 15.11.2021 um 22:51:

Wolfgang,

Can you expand on the following statements from your reply?

You can run Hans example with MkIV and the differences should be even bigger because the check for [] is slower here while in LMTX it's a engine feature. The main difference in LMTX is a extra expansion for \setup compared to \directsetup.

there is no difference between \setup and \directsetup

Are you saying:

1. When [] are used with \setup, expansion of the contents is done differently than when {} are used.

It doesn't matter which form you use for \setup.

What I'm trying to say is that \setup is slower (or better was slower in MkIV) than \directsetup because \setup has to check first if the name is passed within brackets or as normal argument in braces.

The code in MkIV would look similar to this:

\def\setup
  {\doifnextcharelse[
     \setup_brackets
     \setup_braces}

\def\setup_brackets[#1]%
  {\directsetup{#1}}

\def\setup_braces#1%
  {\directsetup{#1}}

2. There is no significant processing time difference between \setup and \directsetup.

When I run the following example on my machine

\starttext

\startsetups [dummy]
\stopsetups

\testfeatureonce{100000}{\setup      {test}} \elapsedtime \par
\testfeatureonce{100000}{\directsetup{test}} \elapsedtime \par

\stoptext

I get these times.

# MkIV

\setup       : 0.136s
\directsetup : 0.079s

# LMTX

\setup       : 0.083 seconds
\directsetup : 0.071 seconds

Add additional stuff in the setup environment and the difference between \setup and \directsetup doesn't matter anymore.

3. There is additional expansion performed for \setup compared to \directsetup.

Although this isn't completely true (but very close) the definition for \setup in LMTX is like this:

\def\setup#1{\directsetup{#1}}

4. Under LMTX, because {} and [] handling overhead is so similar, the most visible processing time difference to users is from the difference in  expansion between \setup and \directsetup.

I think you are saying that 2, 3, and 4 are true, but that 1 is not true.

If that is the case, can you provide an example that demonstrates the difference in expansion between \setup and \directsetup?

Also, as far as expansion, is \fastsetup like \setup or like \directsetup?


\setup and \directsetup are similar. \fastsetup is like the name implies a faster version which ignores grid mode and doesn't care whether the requested environment even exists.

My simple testing shows no difference between setup, directsetup, and fastsetup for namespace set and reset. Is it your understanding that they all behave the same?


No, \fastsetup behaves different because it leaves \relax\empty in the input when you pass the name of a not existing environment.

It shouldn't matter in normal usage but below are two examples.


Example 1:

\starttext

\tex{directsetup}

\scratchcounter 12\directsetup{unknown_a}34

\the\scratchcounter

\tex{fastsetup}

\scratchcounter 12\fastsetup{unknown_b}34

\the\scratchcounter

\stoptext


Example 2:

\starttext

\normalexpanded{\noexpand\firstoftwoarguments\directsetup{unknown_a}xy}

\normalexpanded{\noexpand\firstoftwoarguments\fastsetup{unknown_b}xy}

\stoptext


Wolfgang

--------------5B4D4359A93FF7DC7A38DD92-- --===============3372364702775196431== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============3372364702775196431==--