[texhax] re: grouping
Ross Moore
ross at ics.mq.edu.au
Tue Mar 29 06:53:41 CEST 2005
On 29/03/2005, at 12:54 PM, moheb missaghi wrote:
> Hi Ross,
>
> Thanks for detailed reply. I gathered choosing } in ifnum0=`} had
> something to do with matching parens for example in emacs. My problem
> was with grouping such as for example in the following c snippet:
No, it's not the same as in C, where 'compiling' and 'running'
are separate operations. There you cannot even start to 'run'
until the compilation is error-free.
TeX interprets the string of tokens "on-the-fly";
you can think of it as interweaving the compiling
and running as it goes, it that makes it easier
to understand what happens.
So each '{' or \bgroup or \begingroup needs to be matched
*eventually*.
Sometimes, as with the "argument" to a macro, the ability
to match braces needs to happen immediately; but the code
snippet that you asked about doesn't seem to be one of those.
(Yet it may be, under some circumstances.)
>
> where the open brace in a cannot be closed with close brace in b (you
> get a compiler error). Unless there is a call of b in a such as:
>
> int a()
> {
> printf("something");
> {
> b()
> }
>
> and somehow tex keeps track of unmatched braces across calls. Is that
> the case?
If the open brace just opens a level, then ultimately it ought
to be closed. TeX doesn't need to know where this will happen.
>
> Since you are obviously knowledgeable in tex here are 2 more questions:
>
> 1. It appears that spaces are gobbled such as:
>
> \ifdim \dimen@ >\z@
>
> again in tabularx. So \ifdim\diment@>\z@ is the same?
>
> 2. Why does \show have problem with variables with @ in them? For
> example:
You need to get a copy of The TeXBook and read about \catcode .
That's an early chapter.
Start reading, and allow your self to be drawn in.
>
> \show\@empty
>
> gives:
>
> *\show\@empty
>> \@=macro:
> ->\spacefactor \@m .
> <*> \show\@
> empty
>
> or am I missing something?
Yep; the \catcode concept.
Cheers,
Ross
>
> Thanks again,
>
> Moheb
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 +2 9850 8955
Sydney, Australia fax: +61 +2 9850 8114
------------------------------------------------------------------------
More information about the texhax
mailing list