• No se han encontrado resultados

Determinación del método de estimación económica

CAPÍTULO V: DISCUSIÓN

5.1 Determinación del método de estimación económica

• The replacement text of a macro must be enclosed in explicit beginning and end of group character tokens.

• The open and close braces for boxes,\vadjust, and\insertcan be implicit. This makes it possible to define, for instance

\def\openbox#1{\setbox#1=\hbox\bgroup} \def\closebox#1{\egroup\box#1}

\openbox{15}Foo bar\closebox{15}

• The right-hand side of a token list assignment and the argument of the commands \write,\message,\errmessage,\uppercase,\lowercase,\special, and \markis ahgeneral texti, defined as

hgeneral texti −→ hfilleri{hbalanced textihright bracei

meaning that the left brace can be implicit, but the closing right brace must be an explicit character token with category code 2.

In cases where an implicit left brace suffices, and where expansion is not explicitly inhi- bited, TEX will expand tokens until a left brace is encountered. This is the basis for such constructs as\uppercase\expandafter{\romannumeral80}, which in this unexpan- ded form do not adhere to the syntax. If the first unexpandable token is not a left brace TEX gives an error message.

The grammar of TEX (see Chapter 36) useshleft braceiandhright braceifor explicit cha- racters, that is, character tokens, and{and}for possibly implicit characters, that is, control sequences that have been\letto such explicit characters.

10.4

More about braces

10.4.1 Brace counters

TEX has two counters for keeping track of grouping levels: the master counter and the ba- lance counter. Both of these counters are syntactic counters: they count the explicit brace character tokens, but are not affected by implicit braces (such as\bgroup) that are seman- tically equivalent to an explicit brace.

The balance counter handles braces in all cases except in alignment. Its workings are intui- tively clear: it goes up by one for every opening and down for every closing brace that is not being skipped. Thus

\iffalse{\fi

increases the balance counter if this statement is merely scanned (for instance if it appears in a macro definition text); if this statement is executed the brace is skipped, so there is no effect on the balance counter.

The master counter is more tricky; it is used in alignments instead of the balance counter. This counter records all braces, even when they are skipped such as in\iffalse{\fi. For this counter uncounted skipped braces are still possible: the alphabetic constants‘{and‘} have no effect on this counter when they are use by the execution processor as ahnumberi; they do affect this counter when they are seen by the input processor (which merely sees characters, and not the context).

10.4.2 The brace as a token

Explicit braces are character tokens, and as such they are unexpandable. This implies that they survive until the last stages of TEX processing. For example,

\count255=1{2}

will assign 1 to\count255, and print ‘2’, because the opening brace functions as a deli- miter for the number 1. Similarly

f{f}

will prevent TEX from forming an ‘ff’ ligature.

From the fact that braces are unexpandable, it follows that their nesting is independent of the nesting of conditionals. For instance

\iftrue{\else}\fi

will give an open brace, as conditionals are handled by expansion. The closing brace is simply skipped as part of thehfalse texti; any consequences it has for grouping only come into play in a later stage of TEX processing.

Undelimited macro arguments are either single tokens or groups of tokens enclosed in explicit braces. Thus it is not possible for an explicit open or close brace to be a macro argument. However, braces can be assigned with\let, for instance as in

\let\bgroup={

This is used in the plain\footnotemacro (see page 101).

10.4.3 Open and closing brace control symbols

The control sequences\{and\}do not really belong in this chapter, not being concerned with grouping. They have been defined with\letas synonyms of\lbraceand\rbrace respectively, and these control sequences are\delimiterinstructions (see Chapter 21). The Computer Modern Roman font has no braces, but there are braces in the typewriter font, and for mathematics there are braces of different sizes – and extendable ones – in the extension font.

Chapter 11

Macros

Macros are TEX’s abbreviation mechanism for sequences of commands that are needed more than once, somewhat like procedures in ordinary programming languages. TEX’s pa- rameter mechanism, however, is quite unusual. This chapter explains how TEX macros work. It also treats the commands\letand\futurelet.

\def Start a macro definition. \gdef Synonym for\global\def.

\edef Start a macro definition; the replacement text is expanded at definition time. This command is treated also in the next chapter.

\xdef Synonym for\global\edef.

\csname Start forming the name of a control sequence. \endcsname Stop forming the name of a control sequence.

\global Make the next definition, arithmetic statement, or assignment global.

\outer Prefix indicating that the macro being defined can be used on the ‘outer’ level only.

\long Prefix indicating that the arguments of the macro being defined may contain\par tokens.

\let Define a control sequence to be equivalent to the next token.

\futurelet Define a control sequence to be equivalent to the token after the next token.

11.1

Introduction

A macro is basically a sequence of tokens that has been abbreviated into a control sequence. Statements starting with (among others)\defare called macro definitions, and writing \def\abc{\de f\g}

defines the macro\abc, with the replacement text\de f\g. Macros can be used in this way to abbreviate pieces of text or sequences of commands that have to be given more than once. Any time that TEX’s expansion processor encounters the control sequence\abc, it replaces it by the replacement text.

If a macro should be sensitive to the context where it is used, it can be defined with para- meters:

\def\PickTwo#1#2{(#1,#2)}

takes two arguments and reproduces them in parentheses. The call \PickTwo 12gives ‘(1,2)’.

Documento similar