<< . .

. 25
( : 45)



. . >>

% entering octant ˜ESE™
..controls (6.2624,0.98225) and (8.45786,0)
..(10.85873,0) % segment 0
% entering octant ˜ENE™
Point (1.53745, 9.05345), where there was a vertical tangent, has been rounded to
(2, 9.05348); point (10.85147, ’.00049), where there was a horizontal tangent, has been
rounded to (10.85873, 0); the intermediate control points have been adjusted accord-
ingly. (Rounding of x coordinates has been done separately from y coordinates.)
Finally, with autorounding = 2, additional adjustments are made so that the 45—¦ tran-
sition point will occur at what thinks is a good spot:
Cycle spec at line 15, after subdivision and double autorounding:
(2,9.05348) % beginning in octant ˜SSE™
..controls (2,6.6761) and (3.07103,4.42897)
..(4.78537,2.71463) % segment 0
% entering octant ˜ESE™
..controls (6.46927,1.03073) and (8.62749,0)
..(10.85873,0) % segment 0
% entering octant ˜ENE™
(Notice that 4.78537 + 2.71463 = 7.50000; when the slope is ’1 at a transition point
(x, y), the curve stays as far away as possible from ambiguous points near the transition
if x + y + .5 is an integer.)




´
” PIERRE LE BE, B´le Pr´rie (1601)
e e




” MATTHEW CARTER, Bell Centennial (1978)
(page 208)




25
Summary of
Expressions
Chapter 25: Summary of Expressions 209


We™ve seen that can handle a wide variety of algebraic expressions; expressions
primitive
now it™s time to consolidate what we have learned. The purpose of this chapter hierarchy
and the one that follows is to present a precise and concise summary of everything vacuous
primary
that knows how to do. secondary
We shall be concerned here solely with ™s primitive opera- tertiary
expression
tions, rather than with the higher-level features of the plain base
that comprise the bulk of typical programs. Therefore novice users should put
o¬ reading Chapters 25 and 26 until they feel a need to know what goes on at
the more mundane levels inside the computer. Appendix B contains a summary
of the features of plain , together with a ready-reference guide to the
things that most people want to know about usage.
The remainder of this chapter is set in small type, like that of the present
paragraph, since it is analogous to material that is marked “doubly dangerous” in
other chapters. Instead of using dangerous bend signs repeatedly, let us simply agree
that Chapters 25 and 26 are dangerous by de¬nition.
Chapter 8 introduced the general idea of expressions and the four-fold “pri-
mary, secondary, tertiary, expression” hierarchy on which their syntax is based. -
™s variables can have any of eight types: boolean, numeric, pair, path, pen,
picture, string, and transform. Its expressions can actually have nine di¬erent
types, although the ninth one”“vacuous””is not particularly interesting since it has
only one possible value. Here is the overall syntax:

primary ’’ boolean primary | numeric primary
| pair primary | path primary
| pen primary | future pen primary
| picture primary | string primary
| transform primary | vacuous primary

secondary ’’ boolean secondary | numeric secondary
| pair secondary | path secondary
| pen secondary | future pen secondary
| picture secondary | string secondary
| transform secondary | vacuous secondary

tertiary ’’ boolean tertiary | numeric tertiary
| pair tertiary | path tertiary
| pen tertiary | picture tertiary
| string tertiary | transform tertiary
| vacuous tertiary

expression ’’ boolean expression | numeric expression
| pair expression | path expression
| pen expression | picture expression
| string expression | transform expression
| vacuous expression

We shall discuss the di¬erent types of expressions in alphabetic order; thus, if you are
dying to know what a “vacuous” expression is, you should skip to the end of the chapter.
210 Chapter 25: Summary of Expressions


Boolean expressions were discussed in Chapter 19. The full syntax has one boolean primary
true
more operation, ˜charexists™, that was not mentioned there:
false
(
boolean primary ’’ boolean variable | boolean argument )
| true | false begingroup
| ( boolean expression ) endgroup
known
| begingroup statement list boolean expression endgroup unknown
| known primary | unknown primary cycle
| type primary | cycle primary odd
charexists
| odd numeric primary not
| charexists numeric primary boolean secondary
and
| not boolean primary boolean tertiary
boolean secondary ’’ boolean primary or
| boolean secondary and boolean primary boolean expression
relation
boolean tertiary ’’ boolean secondary ¡
| boolean tertiary or boolean secondary ¡=
boolean expression ’’ boolean tertiary ¿
¿=
| numeric expression relation numeric tertiary =
| pair expression relation pair tertiary ¡¿
shipout
| transform expression relation transform tertiary charcode
| boolean expression relation boolean tertiary tokens
| string expression relation string tertiary parentheses
delimiters
relation ’’ < | <= | > | >= | = | <> delimiters
variable
The expression ˜charexists x™ is true if and only if a shipout command has previously expr
been done with charcode = x. (The value of x is ¬rst rounded to an integer, and argument
reduced to the range 0 ¤ x < 256 by adding or subtracting multiples of 256.) capsule
numeric atom
In these rules, tokens like ˜true™ that appear in typewriter type stand for any normaldeviate
(
tokens whose current meaning is the same as the meaning of ˜true™ when
)
starts from scratch; the particular token ˜true™”whose meaning may indeed change as begingroup
a program runs”is not really involved. endgroup
numeric token primary
The special tokens ˜(™ and ˜)™ in these rules do not refer to parentheses; they
/
refer to any matching pair of delimiters de¬ned by a delimiters command.
A boolean variable denotes a variable whose type is boolean; a numeric
variable is a variable whose type is numeric; and so on. The syntax for variable
was discussed in Chapter 7. A boolean argument is an expr argument to a macro,
where the value of the expression is of type boolean; expr arguments are put into
special “capsule” tokens as explained in Chapter 18.
Numeric expressions have the richest syntax of all, because they form the
nucleus of the entire language:
numeric atom ’’ numeric variable | numeric argument
| numeric token primary
| internal quantity
| normaldeviate
| ( numeric expression )
| begingroup statement list numeric expression endgroup
numeric token primary ’’ numeric token / numeric token
| numeric token not followed by ˜/ numeric token ™
Chapter 25: Summary of Expressions 211


numeric primary ’’ numeric atom numeric primary
| numeric atom [ numeric expression , numeric expression ] [
,
| length numeric primary | length pair primary ]
| length path primary | length string primary length
length
| ASCII string primary | oct string primary | hex string primary length
| pair part pair primary | transform part transform primary length
| angle pair primary ASCII
oct
| turningnumber path primary | totalweight picture primary hex
| numeric operator numeric primary angle
| directiontime pair expression of path primary turningnumber
totalweight
pair part ’’ xpart | ypart directiontime
transform part ’’ pair part | xxpart | xypart | yxpart | yypart of
pair part
numeric operator ’’ sqrt | sind | cosd | mlog | mexp xpart
| floor | uniformdeviate | scalar multiplication operator ypart
scalar multiplication operator ’’ plus or minus transform part
xxpart
| numeric token primary not followed by + or - or a numeric token xypart
numeric secondary ’’ numeric primary yxpart
yypart
| numeric secondary times or over numeric primary numeric operator
times or over ’’ * | / sqrt
numeric tertiary ’’ numeric secondary sind
cosd
| numeric tertiary plus or minus numeric secondary mlog
| numeric tertiary Pythagorean plus or minus numeric secondary mexp
¬‚oor
plus or minus ’’ + | - uniformdeviate
Pythagorean plus or minus ’’ ++ | +-+ scalar multiplication operator
numeric expression ’’ numeric tertiary numeric secondary
times or over
*
Each of the operations mentioned in this syntax has already been explained somewhere /
in this book; Appendix I tells where. numeric tertiary
plus or minus
This is a good time to list all of the internal quantities that are initially present +
-
:
in Pythagorean plus or minus
++
tracingtitles show titles online when they appear +-+
tracingequations show each variable when it becomes known numeric expression
tracingtitles
tracingcapsules show capsules as well as variables tracingequations
tracingchoices show the control points chosen for paths tracingcapsules
tracingchoices
tracingspecs show subdivision of paths into octants before digitizing
tracingspecs
tracingpens show vertices of pens as they are made from future pens tracingpens
tracingcommands show commands and operations before they™re performed tracingcommands
tracingrestores
tracingrestores show when a symbol or internal quantity is restored
tracingmacros
tracingmacros show macros before they are expanded tracingedges
tracingedges show digitized edges as they are computed tracingoutput
tracingonline
tracingoutput show digitized edges as they are output tracingstats
tracingonline show long diagnostics on the terminal and in the log pausing
showstopping
tracingstats log the memory usage at end of job
fontmaking
pausing show lines on the terminal before they are read proo¬ng
showstopping stop after each show command
fontmaking produce font metric output
proo¬ng produce proof mode output
212 Chapter 25: Summary of Expressions


turningcheck reorient clockwise paths, ¬‚ag strange ones turningcheck
warningcheck
warningcheck advise when a variable value gets large
smoothing
smoothing remove certain glitches from digitized curves autorounding
autorounding move paths to “good” tangent points granularity
¬llin
granularity the pixel size for autorounding year
¬llin the extra darkness of diagonals (to be counteracted) month
day
year the current year (e.g., 1986)
time
the current month (e.g, 3 ≡ March)
month charcode
day the current day of the month charext
charwd
time the number of minutes past midnight when job started
charht
charcode the number of the next character to be output chardp
charext the extension code of the next character to be output charic
chardx
charwd the width of the next character to be output, in points chardy
charht the height of the next character to be output, in points designsize
hppp
chardp the depth of the next character to be output, in points
vppp
charic the italic correction of the next character, in points xo¬set
chardx the device™s x movement for the next character, in pixels yo¬set
boundarychar
chardy the device™s y movement for the next character, in pixels
pair primary
designsize the approximate size of the current typeface, in points (
hppp the number of horizontal pixels per point ,
)
vppp the number of vertical pixels per point (
xo¬set the horizontal displacement of shipped-out characters )
begingroup
yo¬set the vertical displacement of shipped-out characters
endgroup
boundarychar the right boundary character for ligatures and kerns [
,
All of these quantities are numeric. They are initially zero at the start of a job, ]
point
except for year , month , day , and time , which are initialized to the time the run
of
began; furthermore, boundarychar is initially ’1. A granularity of zero is equivalent precontrol
to granularity = 1. A preloaded base ¬le like plain will usually give nonzero of
postcontrol
values to several other internal quantities on this list.
of
peno¬set
Now we come to expressions of type pair, which are the second most important of
elements of programs: peno¬set
of
pair primary ’’ pair variable | pair argument pair secondary
*
| ( numeric expression , numeric expression )
| ( pair expression )
| begingroup statement list pair expression endgroup
| numeric atom [ pair expression , pair expression ]
| scalar multiplication operator pair primary
| point numeric expression of path primary
| precontrol numeric expression of path primary
| postcontrol numeric expression of path primary
| penoffset pair expression of pen primary
| penoffset pair expression of future pen primary
pair secondary ’’ pair primary
| pair secondary times or over numeric primary
| numeric secondary * pair primary
| pair secondary transformer
Chapter 25: Summary of Expressions 213


transformer ’’ rotated numeric primary transformer
| scaled numeric primary rotated
scaled
| shifted pair primary shifted
| slanted numeric primary slanted
transformed
| transformed transform primary xscaled
| xscaled numeric primary yscaled
| yscaled numeric primary zscaled
pair tertiary
| zscaled pair primary intersectiontimes
pair tertiary ’’ pair secondary pair expression
| pair tertiary plus or minus pair secondary path primary
(
| path tertiary intersectiontimes path secondary )
pair expression ’’ pair tertiary begingroup
endgroup
makepath
A pair is a special case of a path (namely, it™s a path of length zero); Chapter 19
makepath
explains that doesn™t change the type from pair to path unless there is no reverse
other way to meet the syntax rules. subpath
of
Speaking of paths, they come next in our survey: path secondary
path tertiary
path primary ’’ pair primary | path variable | path argument path subexpression
path join
| ( path expression ) direction speci¬er
| begingroup statement list path expression endgroup “
| makepath pen primary | makepath future pen primary curl
˝
| reverse path primary “
| subpath pair expression of path primary ˝
path secondary ’’ pair secondary | path primary “
,
| path secondary transformer ˝
path tertiary ’’ pair tertiary | path secondary basic path join
&
path subexpression ’’ path expression ..
| path subexpression path join path tertiary ..
path join ’’ direction speci¬er basic path join direction speci¬er ..
..
direction speci¬er ’’ empty ..
| { curl numeric expression } tension
| { pair expression } tension
tension
| { numeric expression , numeric expression } and
basic path join ’’ & tension amount
atleast
| .. controls
| .. tension .. controls
| .. controls .. controls
and
tension ’’ tension tension amount path expression
| tension tension amount and tension amount cycle
tension amount ’’ numeric primary
| atleast numeric primary
controls ’’ controls pair primary
| controls pair primary and pair primary
path expression ’’ pair expression | path tertiary
| path subexpression direction speci¬er
| path subexpression path join cycle
Chapter 14 tells all about path creation.
214 Chapter 25: Summary of Expressions


Pens and future pens coexist as follows: pen primary
nullpen
pen primary ’’ pen variable | pen argument (
)
| nullpen begingroup
| ( pen expression ) endgroup
| begingroup statement list pen expression endgroup future pen primary
pencircle
future pen primary ’’ pencircle makepen
| makepen path primary pen secondary
pen secondary ’’ pen primary future pen secondary
pen tertiary
future pen secondary ’’ future pen primary pen expression
| future pen secondary transformer picture primary
nullpicture
| pen secondary transformer (
pen tertiary ’’ pen secondary )
| future pen secondary begingroup
endgroup
pen expression ’’ pen tertiary picture secondary
picture tertiary
See Chapter 16 for a thorough discussion of pen usage. picture expression
string primary
Pictures can be null, added, or subtracted: jobname
readstring
picture primary ’’ picture variable | picture argument (
| nullpicture )
begingroup
| ( picture expression ) endgroup
| begingroup statement list picture expression endgroup str
| plus or minus picture primary char
decimal
picture secondary ’’ picture primary substring
| picture secondary transformer of
picture tertiary ’’ picture secondary string secondary
string tertiary

<< . .

. 25
( : 45)



. . >>