# [NTG-context] Malicious little bugger

Hans Hagen pragma at wxs.nl
Mon Jul 3 10:43:14 CEST 2006

Aditya Mahajan wrote:
> On Sun, 2 Jul 2006, David Arnold wrote:
>
>
>> Sanjoy,
>>
>> Of course. Thanks.
>>
>> But how about an example in latex or tex where a function eats a
>> brace and crashes, as what happens with this context code:
>>
>>  \placeformula[-]
>>  \startformula
>>  [9,\infty)=\{x:\,x\ge 9\}
>>  \stopformula
>>
>> I know I've seen this in Latex before, but I can't remember where.
>>
>
>
>   \begin{aligned}
>     [g,\infty)=\{...\}
>   \end{aligned}
>
>
> The package mathtools enforces that the optional arguments of aligned
> et al. should come in the same line, that is
>
> \begin{aligned}[t] takes "t" as an optional arguments which
>
> \begin{aligned}
> [t]
>
that only can work if one gives the end of line characters a different
catcode; a side effect is that the lookahead may fail when the formula
is passed in a macro so it will never be robust
> does not.
>
> I do not think that this can be ever enforced in Context, because a
> lot of Context code is written like
>
> \definesomething
>    [somename]
>    [some options]
>
> \dosingleempty et al, could be changed to stop scanning on a newline,
> but I am certain it will break some of the internals.
>
indeed,

for tex (unless one messes around with the endline char)

\define[]
\define []
\define      []
\define
[]

is the same, and in order to be consistent, context even does some
explicit testing so that intermediate newlines and spaces are gobbles
(when non standard), think of:

\define[][]
\define[] []
\define []
[]

why should we treat spaces between \define [] and [] [] differently?

anyhow, it dates back a long time, is rather optimized, and will not change

Hans