From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107885 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Jairo A. del Rio" Newsgroups: gmane.comp.tex.context Subject: Re: Commands with arguments before in ConTeXt Date: Mon, 29 Jun 2020 05:15:03 -0500 Message-ID: References: <64d592a1-149a-d2ec-5979-b000e5096c26@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6218487564744009627==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="78244"; mail-complaints-to="usenet@ciao.gmane.io" To: Hans Hagen , mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Jun 29 12:15:40 2020 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 1jpqpA-000KEl-Bb for gctc-ntg-context-518@m.gmane-mx.org; Mon, 29 Jun 2020 12:15:40 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0682D18532F; Mon, 29 Jun 2020 12:15:18 +0200 (CEST) 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 V3wYAPziRGif; Mon, 29 Jun 2020 12:15:17 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0C15318532B; Mon, 29 Jun 2020 12:15:17 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5E94A185328 for ; Mon, 29 Jun 2020 12:15:16 +0200 (CEST) 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 babu_N7v_VcU for ; Mon, 29 Jun 2020 12:15:15 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.41; helo=mail-wm1-f41.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 6D0B3184E98 for ; Mon, 29 Jun 2020 12:15:15 +0200 (CEST) Original-Received: by mail-wm1-f41.google.com with SMTP id o2so15556588wmh.2 for ; Mon, 29 Jun 2020 03:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=RTHXdINAix8e0knA513i3U0miF9XxafT0m0Od4bLQb4=; b=YmJL4R0thC3vzPFRRGLHUX8EBX+X+K9J0kRxwNBrwM5hLWl6+NnIgmfFwy6mskDx6Z YIN9ZzCtsLMKkdwLH6FCHNs3AXXunL0lnf0/DXfr3uKaxf+WCYtgcnxRDEqGuJAuiZY5 GCnOzCLv1rf5pcvV0EAPQwOF+HBtb45vDWHlDv6ESniQNBHS1v7OPUHCzPy3FRr0pjYA 7Jl+f5OTjOdJ+cdy0MpHp66YbKg0XEA/SsL1wHpQ8XBfw3DSRXPsqmzpmqqY/Vm2wzfq 7hlQ8zgMqA3PGAPcGF+Z+33JUfCUHpGlvebuV2G9qk70zQr+ygVYd4i6lgBv8q2hcsF2 k4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=RTHXdINAix8e0knA513i3U0miF9XxafT0m0Od4bLQb4=; b=fsRYwvLX28+Z2ToJ0AJtg8tD4xacH+5C7NSK2aF+PDbLhjXGM1bciKgaIiC6j3nUu4 VkvWwuKV901RnmJ/FNGBVk6FslNBHL/+vUAgLC/8iu1vFI6dGdtglYIAmAcxCzCeJ1xi BNeJ+d//C3k7EFhvDVShsrr4PMai9T0Pq0SJc+F3/2Ex/Kl7LBfmkrxG3XInYBvIxjZP n2F6d8kp48WBFycN6IvqEbvv12JGIC/1OU23iCwSGyLcmWjH2rEuwF/4aDt/9FIYOwqL e8Jmv49GzrZ/JyTGEHFmrK3XZPr9Ih6uuvKhtEt3HP8H568RCgZLVvzAZS1f2N7d//e1 ymUw== X-Gm-Message-State: AOAM530STYEmv21ENNNaHWV6m2/q0BS0/KMpXj4YmtyK+MrYU+rMNBJK h9wF3KqhgE/a+9hyP582nEElXo0ki0t7qnlTAaU= X-Google-Smtp-Source: ABdhPJxIpT51NYZ+CLKeRl5pEV4mzHqEL+b7icAX0lrffgFkwlQn2+/bXmjNs7UerWLjjkNs3g6K7cLTyuWCPXorBSo= X-Received: by 2002:a7b:c84d:: with SMTP id c13mr16001818wml.170.1593425715052; Mon, 29 Jun 2020 03:15:15 -0700 (PDT) In-Reply-To: <64d592a1-149a-d2ec-5979-b000e5096c26@xs4all.nl> 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:107885 Archived-At: --===============6218487564744009627== Content-Type: multipart/alternative; boundary="000000000000b8c20a05a9365545" --000000000000b8c20a05a9365545 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hans, after your explanation I'm actually curious now about details, but my knowledge is too limited now (maybe reading source codes would be better? Worse?). I do a bit of C, but I don't know about Pascal at all and I'm not sure where to start from in order to understand TeX better. Well, at least I know why that feature isn't supported. I'll be thankful for any references. Thank you very much. Jairo :) El lun., 29 de jun. de 2020 a la(s) 02:28, Hans Hagen (j.hagen@xs4all.nl) escribi=C3=B3: > On 6/28/2020 10:48 PM, Jairo A. del Rio wrote: > > I've read the following is not possible in TeX > > > > \def#1\macro{blabla#1} > > > > where arguments come before. The only partial exceptions are commands > > like \atop or \over, which are in fact primitives. Is there a way to do > > this in ConTeXt? > > > > Could it be a feature request for LuaMetaTeX? I've seen Hans > > experimenting a lot with new primitives and new possibilities for > > arguments, like #0 and co., so I ask in case it's not too nonsensical t= o > > propose it. Regards > Every \foo will be looked up, so by the time \macro in: > > bla bla {\bf xxx}\macro{xxx} > > is seen, the {\bf xxx} is already passed and processed. TeX never looks > back, which actually would make for a pretty complex multipass parsing > and expansion management (forward control and backward: \expandafter > would then also have an \expandbefore companion). Even in the simple > case: should it keep track of quantities done (grouped, single token, > box, etc.) and then in retrospect see it as #1 (them being nodes by now > and not tokens)? > > So, why in math but not in text? The \atop and \over (those are > basically all the same command but with a different treatment > afterwards) are an exception: (1) tex knows that is is in math mode, and > in math mode the { } are not really arguments but defines some stuff > handled together. Much processing (not all) is delayed to a second pass, > so {1}\over{2} internally becomes \over{1}{2} and even that is kind of > tricky because there are math styles involved (which makes for some hard > coded behaviour that in the perspective of luametatex i try to get more > grip on). Now, in order to handle this one (!) exception to lookahead > parsing, special tracking happens in math mode, the previous math > grouped stuff is registered and adapted to the \over when seen, > otherwise it stays as is. This exception also maked the code somewhat > messier because there are several spots where it has to be dealt with > (also think of saving and restoring states). Just imagine that there > were more such commands. Believe me, you really don't want to know the > details. > > So the answer is "Can't be done without overhauling the whole concept". > > Now, I know that the narrative is that context is a moving target > (contrary to other macro packages that don't / can't change because > users / publishers expect them to behave the same forever) so one can > argue that for context we can follow a drastic different route, but even > then, we can't shoot ourselves in the foot too often. I know that some > people (read: Alan) love these {{}\foo{}} syntaxes but live would have > been simpler if even \over has not be in there with prefix notation > (there is a reason why macro package have \frac like variants). > > 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 > ----------------------------------------------------------------- > --000000000000b8c20a05a9365545 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hans, after your explanation I'm actu= ally curious now about details, but my knowledge is too limited now (maybe = reading source codes would be better? Worse?). I do a bit of C, but I don&#= 39;t know about Pascal at all and I'm not sure where to start from in o= rder to understand TeX better. Well, at least I know why that feature isn&#= 39;t supported. I'll be thankful for any references. Thank you very muc= h.

Jairo :)

El lun., 29 de jun. de 2020 a la(s) 02:28,= Hans Hagen (j.hagen@xs4all.nl) es= cribi=C3=B3:
On = 6/28/2020 10:48 PM, Jairo A. del Rio wrote:
> I've read the following is not possible in TeX
>
> \def#1\macro{blabla#1}
>
> where arguments come before. The only partial exceptions are commands =
> like \atop or \over, which are in fact primitives. Is there a way to d= o
> this in ConTeXt?
>
> Could it be a feature request for LuaMetaTeX? I've seen Hans
> experimenting a lot with new primitives and new possibilities for
> arguments, like #0 and co., so I ask in case it's not too nonsensi= cal to
> propose it. Regards
Every \foo will be looked up, so by the time \macro in:

=C2=A0 =C2=A0bla bla {\bf xxx}\macro{xxx}

is seen, the {\bf xxx} is already passed and processed. TeX never looks back, which actually would make for a pretty complex multipass parsing
and expansion management (forward control and backward: \expandafter
would then also have an \expandbefore companion). Even in the simple
case: should it keep track of quantities done (grouped, single token,
box, etc.) and then in retrospect see it as #1 (them being nodes by now and not tokens)?

So, why in math but not in text? The \atop and \over (those are
basically all the same command but with a different treatment
afterwards) are an exception: (1) tex knows that is is in math mode, and in math mode the { } are not really arguments but defines some stuff
handled together. Much processing (not all) is delayed to a second pass, so {1}\over{2} internally becomes \over{1}{2} and even that is kind of
tricky because there are math styles involved (which makes for some hard coded behaviour that in the perspective of luametatex i try to get more grip on). Now, in order to handle this one (!) exception to lookahead
parsing, special tracking happens in math mode, the previous math
grouped stuff is registered and adapted to the \over when seen,
otherwise it stays as is. This exception also maked the code somewhat
messier because there are several spots where it has to be dealt with
(also think of saving and restoring states). Just imagine that there
were more such commands. Believe me, you really don't want to know the =
details.

So the answer is "Can't be done without overhauling the whole conc= ept".

Now, I know that the narrative is that context is a moving target
(contrary to other macro packages that don't / can't change because=
users / publishers expect them to behave the same forever) so one can
argue that for context we can follow a drastic different route, but even then, we can't shoot ourselves in the foot too often. I know that some =
people (read: Alan) love these {{}\foo{}} syntaxes but live would have
been simpler if even \over has not be in there with prefix notation
(there is a reason why macro package have \frac like variants).

Hans



-----------------------------------------------------------------
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Hans Hagen | PRAGMA ADE
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ridderstraat 27 | 80= 61 GH Hasselt | The Netherlands
=C2=A0 =C2=A0 =C2=A0 =C2=A0 tel: 038 477 53 69 | www.pragma-ade.nl | www.= pragma-pod.nl
-----------------------------------------------------------------
--000000000000b8c20a05a9365545-- --===============6218487564744009627== 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== --===============6218487564744009627==--