ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* What does #+ do?
@ 2020-07-14  0:08 Jairo A. del Rio
  2020-07-14  0:35 ` Jairo A. del Rio
  2020-07-14  3:53 ` Wolfgang Schuster
  0 siblings, 2 replies; 3+ messages in thread
From: Jairo A. del Rio @ 2020-07-14  0:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 723 bytes --]

Hi list!

In evenmore pp. 76-77, concerning LMTX extended macro parsing, the
following examples of #0, #+ and #- are given

\def\TestA#1#2#3{{(#1)(#2)(#3)}}
\def\TestB#1#0#3{(#1)(#2)(#3)}
\def\TestC#1#+#3{(#1)(#2)(#3)}
\def\TestD#1#-#2{(#1)(#2)}

So

\TestA1{\red 2}3
\TestB1{\red 2}3
\TestC1{\red 2}3
\TestD1{\red 2}3

give

(1)(2)(3) % red from "2" onward
(1)()(3)
(1)(2)(3) % only "2" is colored
(1)(3)

What I guess is that #+ pass an argument, grouping braces included (the
report says an argument is passed "as-is"). I see it as really useful. But,
apart from the example above, are there any other differences between
doing, say, \def\foo#1#2#3 and \def\foo#+#+#+{#1#2#3}? Thank you very much.

Cordially,

Jairo :)

[-- Attachment #1.2: Type: text/html, Size: 988 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: What does #+ do?
  2020-07-14  0:08 What does #+ do? Jairo A. del Rio
@ 2020-07-14  0:35 ` Jairo A. del Rio
  2020-07-14  3:53 ` Wolfgang Schuster
  1 sibling, 0 replies; 3+ messages in thread
From: Jairo A. del Rio @ 2020-07-14  0:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1001 bytes --]

Hi.
Sorry, I meant \def\foo#1#2#3{#1#2#3} and \def\foo#+#+#+{#1#2#3}.

Jairo :)

El lun., 13 de jul. de 2020 a la(s) 19:08, Jairo A. del Rio (
jairoadelrio6@gmail.com) escribió:

> Hi list!
>
> In evenmore pp. 76-77, concerning LMTX extended macro parsing, the
> following examples of #0, #+ and #- are given
>
> \def\TestA#1#2#3{{(#1)(#2)(#3)}}
> \def\TestB#1#0#3{(#1)(#2)(#3)}
> \def\TestC#1#+#3{(#1)(#2)(#3)}
> \def\TestD#1#-#2{(#1)(#2)}
>
> So
>
> \TestA1{\red 2}3
> \TestB1{\red 2}3
> \TestC1{\red 2}3
> \TestD1{\red 2}3
>
> give
>
> (1)(2)(3) % red from "2" onward
> (1)()(3)
> (1)(2)(3) % only "2" is colored
> (1)(3)
>
> What I guess is that #+ pass an argument, grouping braces included (the
> report says an argument is passed "as-is"). I see it as really useful. But,
> apart from the example above, are there any other differences between
> doing, say, \def\foo#1#2#3 and \def\foo#+#+#+{#1#2#3}? Thank you very much.
>
> Cordially,
>
> Jairo :)
>

[-- Attachment #1.2: Type: text/html, Size: 1491 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: What does #+ do?
  2020-07-14  0:08 What does #+ do? Jairo A. del Rio
  2020-07-14  0:35 ` Jairo A. del Rio
@ 2020-07-14  3:53 ` Wolfgang Schuster
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Schuster @ 2020-07-14  3:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Jairo A. del Rio schrieb am 14.07.2020 um 02:08:
> Hi list!
> 
> In evenmore pp. 76-77, concerning LMTX extended macro parsing, the 
> following examples of #0, #+ and #- are given
> 
> \def\TestA#1#2#3{{(#1)(#2)(#3)}}
> \def\TestB#1#0#3{(#1)(#2)(#3)}
> \def\TestC#1#+#3{(#1)(#2)(#3)}
> \def\TestD#1#-#2{(#1)(#2)}
> 
> So
> 
> \TestA1{\red 2}3
> \TestB1{\red 2}3
> \TestC1{\red 2}3
> \TestD1{\red 2}3
> 
> give
> 
> (1)(2)(3) % red from "2" onward
> (1)()(3)
> (1)(2)(3) % only "2" is colored
> (1)(3)
> 
> What I guess is that #+ pass an argument, grouping braces included (the 
> report says an argument is passed "as-is"). I see it as really useful. 
> But, apart from the example above, are there any other differences 
> between doing, say, \def\foo#1#2#3 and \def\foo#+#+#+{#1#2#3}? Thank you 
> very much.

It's usefull when you use optional arguments because TeX removes the 
braces around the content of the argument.

\starttext

\def\testa[#1]{\detokenize{#1}}
\def\testb[#+]{\detokenize{#1}}

\testa[{braces}]

\testb[{braces}]

\stoptext

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-14  3:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  0:08 What does #+ do? Jairo A. del Rio
2020-07-14  0:35 ` Jairo A. del Rio
2020-07-14  3:53 ` Wolfgang Schuster

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).