On 1/10/2025 11:04 PM, Henning Hraban Ramm wrote:
Am 10.01.25 um 19:45 schrieb Hans Hagen:
\tolerant\def\MyMacro[#1]#:#2%
{\ifparameter#1\or
(#1)
\fi
/#2/}
\MyMacro[one]{two}
\MyMacro{two}
Oops, another variant that I didn’t know.
I must unlearn my remaining MkII stuff…
When should I use brackets or other characters in a definition, when
not?
optionals normally have []
Yes, of course, but I’m often surprised by funny characters like #:
Well, there are reasons: It has to fit in the #1 .. #9 approach because
these things are stored into tokens, so single character. Then one has
to decide on what characters. There's also a performance issue because
we don't want to sacrifice too much and these preamble tokens are
"parsed" every time a macro is called so they better can be efficient.
In the end only a few users (mostly developers) will see the obscure
ones (and understand why some are there). The \optional prefix enables
these extensions. It's a bit like: I want to grab arguments with mandate
{} and there is something so let's look it up. Or, I bet that one can
grab \par's so lets the manual for that.
Did you know that we can have #A..#E as well. So 15 parameters instead
of 9? I still need to use that more (deep down).
Which docs should I read?
how about lowlevel-macros .. but haven't you read all of them by now ?
Apparently not diligently enough.
If at all. Can’t remember any more.
Don't worry, you don't want to know what I forget.
I’m not competent enough to rewrite e.g.
https://wiki.contextgarden.net/System_Macros/Handling_Arguments
Sigh.
So you haven't reached Wolfgang level yet, and by the time you have, he
bumped the scale up again, so don't sigh too much ... won't help,
actually your upcoming manual will cover plenty, so more of a hurray.
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 /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________