From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107897 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 19:18:09 -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="===============4046718384823716131==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="91922"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users , taco@elvenkind.com Original-X-From: ntg-context-bounces@ntg.nl Tue Jun 30 02:18:56 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 1jq3zE-000NqD-90 for gctc-ntg-context-518@m.gmane-mx.org; Tue, 30 Jun 2020 02:18:56 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 844401853A9; Tue, 30 Jun 2020 02:18:26 +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 AU0Uy17FVq6I; Tue, 30 Jun 2020 02:18:25 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 42DB61853AA; Tue, 30 Jun 2020 02:18:25 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 1D7881853A7 for ; Tue, 30 Jun 2020 02:18:23 +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 sD1Qc0a3iSWc for ; Tue, 30 Jun 2020 02:18:21 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.54; helo=mail-wr1-f54.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 A8B61184C0B for ; Tue, 30 Jun 2020 02:18:21 +0200 (CEST) Original-Received: by mail-wr1-f54.google.com with SMTP id k6so18366147wrn.3 for ; Mon, 29 Jun 2020 17:18:21 -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=kWcL19Pps28OQQkNgaG4TfeKHxJaTcj73Kn0U4Zt37k=; b=ZqeYI5WWHwJbjH5YsPJiPDLpc4GQlVtbNLx1f62J5Afx5jTEsI/aw7RVlZdroJcGot zoXv0STW68E3rR5CPqf4rZN4sWQBa3CUBtYU5gtw7LkZbtwtvQjQMcNXQ1GoEMssKDH7 uq3l2k3k6LALreJHQxTBhWfFMSNQeUw6HAYAeyZ9Rkh3EQiQtfW0++RXkDaFh6NeMRRm Otp2tJr4Bxpp7JIBMrs2YiZMBDwY4jGkWDdcj7E6nZl9Tg6mrC/336UpjKvTXRRnwWgm ei00xoaGaoVZN/fvl8ZQY9yKmACluOMLJpZhvMTaWQOGMFZs5rnjJJL3HZ1ooaS5kKds Ewog== 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=kWcL19Pps28OQQkNgaG4TfeKHxJaTcj73Kn0U4Zt37k=; b=tVToUknZarj1VYd3z5YLwnomrNOKkegjy7zhy3ldso75vhG58De4LIi9DGk16oz2r0 7N5IeGoAJDVeYJn7noHFmEtuM4lXL7kpVLfHtC5RWY8QNnVdGvs/rq47cUWZBpmuT5FG NiCLaKXygRjKkHN0DQsAux7Dyy0NyoJmLme2+GsummAQyO/KKFIRlX/ZZ+qU04PXE9dP rOxbIdvzQuRh7v0cF1z48FXTKqgMABfzEx5FftVTUMEkMSddoenQrpDLdO6sFPRb/XNK iYhdvboees2eQq75WHsBSGPLh5httf99Y4Z1QVO3xHjbDvwi9dxO3a3voC/oOizakqsx b8EA== X-Gm-Message-State: AOAM532r2iYZYueFCUODwqfCq5CoIT/ccNURqGCIhgssfu1I9KeFkuPC 85012cJYfJa6EjmK6PfLyrTm5QH/FP4t8FJWu72PKZ68 X-Google-Smtp-Source: ABdhPJxapoVeWU4BpTXXH8RIfQP5upseJfBJ7JJnfG3Zsr+jWVyYqkD5OVGy7zXczKx2NSudNyBM7i8NeV8Y21i6C+o= X-Received: by 2002:adf:f885:: with SMTP id u5mr18877231wrp.402.1593476300950; Mon, 29 Jun 2020 17:18:20 -0700 (PDT) In-Reply-To: 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:107897 Archived-At: --===============4046718384823716131== Content-Type: multipart/alternative; boundary="000000000000e050fd05a9421c98" --000000000000e050fd05a9421c98 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'll take a look at it. Thank you a lot, Taco. Regards, Jairo :) El lun., 29 de jun. de 2020 a la(s) 05:36, Taco Hoekwater ( taco@elvenkind.com) escribi=C3=B3: > Hi, > > Oversimplifying: > > TeX (and derivatives like luatex) read the input file as a list of > operators with optional suffix arguments. > > In normal (text) mode, there is no expression state maintained except > inside the handling of such optional arguments. > > It follows that, if there is a top-level text input like > > a\bold{a} > > TeX treats this as (assuming =E2=80=99simple=E2=80=99 macro definitions): > > command a (no arguments) > command \bold (a macro with one one braced argument) > > And by the time =E2=80=9C\bold" is seen, the =E2=80=9Ca=E2=80=9D command= has already been > processed completely. > > > In math mode, there *is* an expression state maintained, and that is why > \over and \atop work. > > > For further information and actual details, you can just look at the > luatex source (it is in C): > > > https://github.com/TeX-Live/luatex/blob/trunk/source/texk/web2c/luatexdir= /tex/maincontrol.c > > The function > > void main_control(void) > > is the one that does all the heavy lifting (using a dispatch table). > > Taco > > > On 29 Jun 2020, at 12:15, Jairo A. del Rio > wrote: > > > > Hans, after your explanation I'm actually curious now about details, bu= t > 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 an= d > 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 an= y > references. Thank you very much. > > > > Jairo :) > > > > El lun., 29 de jun. de 2020 a la(s) 02:28, Hans Hagen (j.hagen@xs4all.n= l) > 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 > to > > > 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, an= d > > 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 har= d > > 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 eve= n > > 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 > > ----------------------------------------------------------------- > > > _________________________________________________________________________= __________ > > 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 > > > _________________________________________________________________________= __________ > > Taco Hoekwater > Elvenkind BV > > > > > > _________________________________________________________________________= __________ > 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 > > _________________________________________________________________________= __________ > --000000000000e050fd05a9421c98 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'll take a look at it. Thank you a lot, Taco.
Regards,

Jairo :)

El lun., 29 de= jun. de 2020 a la(s) 05:36, Taco Hoekwater (taco@elvenkind.com) escribi=C3=B3:
Hi,

Oversimplifying:

TeX (and derivatives like luatex) read the input file as a list of operator= s with optional suffix arguments.

In normal (text) mode, there is no expression state maintained except insid= e the handling of such optional arguments.

It follows that, if there is a top-level text input like

=C2=A0 a\bold{a}

TeX treats this as (assuming =E2=80=99simple=E2=80=99 macro definitions):
=C2=A0 command a=C2=A0 =C2=A0 =C2=A0(no arguments)
=C2=A0 command \bold (a macro with one one braced argument)

And by the time =E2=80=9C\bold" is seen, the=C2=A0 =E2=80=9Ca=E2=80=9D= command has already been processed completely.


In math mode, there *is* an expression state maintained, and that is why \o= ver and \atop work.


For further information and actual details, you can just look at the luatex= source (it is in C):

=C2=A0 ht= tps://github.com/TeX-Live/luatex/blob/trunk/source/texk/web2c/luatexdir/tex= /maincontrol.c

The function

=C2=A0 void main_control(void)

is the one that does all the heavy lifting (using a dispatch table).

Taco

> On 29 Jun 2020, at 12:15, Jairo A. del Rio <jairoadelrio6@gmail.com> wrote= :
>
> Hans, after your explanation I'm actually curious now about detail= s, 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 t= hankful 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 comm= ands
> > 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 non= sensical to
> > propose it. Regards
> Every \foo will be looked up, so by the time \macro in:
>
>=C2=A0 =C2=A0 bla bla {\bf xxx}\macro{xxx}
>
> is seen, the {\bf xxx} is already passed and processed. TeX never look= s
> back, which actually would make for a pretty complex multipass parsing=
> and expansion management (forward control and backward: \expandafter <= br> > would then also have an \expandbefore companion). Even in the simple <= br> > 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 no= w
> 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, a= nd
> in math mode the { } are not really arguments but defines some stuff <= br> > handled together. Much processing (not all) is delayed to a second pas= s,
> 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 ha= rd
> coded behaviour that in the perspective of luametatex i try to get mor= e
> 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 <= br> > 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 be= cause
> users / publishers expect them to behave the same forever) so one can =
> argue that for context we can follow a drastic different route, but ev= en
> 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=A0 Hans Hagen | PRAGMA ADE
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Ridderstraat 27= | 8061 GH Hasselt | The Netherlands
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tel: 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 / http://www.ntg.nl/mailman/listin= fo/ntg-context
> webpage=C2=A0 : http://www.pragma-ade.nl / http://context.aanhet.ne= t
> archive=C2=A0 : https://bitbucket.org/phg/cont= ext-mirror/commits/
> wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
> ______________________________________________________________________= _____________

Taco Hoekwater
Elvenkind BV




___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://context.aanhet.net=
archive=C2=A0 : https://bitbucket.org/phg/context-m= irror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________
--000000000000e050fd05a9421c98-- --===============4046718384823716131== 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== --===============4046718384823716131==--