throbber
PostScript'
`
`T79inlaz'ng in
`
`#
`
`Petltloner App e Inc. - EX 1 1t 1040, Cover
`
`Petitioner Apple Inc. - Exhibit 1040, Cover
`
`

`
`
`
`Thinking in
`PostScrıpt(cid:226)
`
`Petitioner Apple Inc. - Exhibit 1040, p. i
`
`

`
`Petitioner Apple Inc. - Exhibit 1040, p. ii
`
`Petitioner Apple Inc. - Exhibit 1040, p. ii
`
`

`
`
`
`
`
`
`Thinking in
`PostScrıpt(cid:226)
`
`Glenn C. Reid
`
`Addison-Wesley Publishing Company, Inc.
`Reading, Massachusetts • Menlo Park, California • New York
`Don Mills, Ontario • Wokingham, England • Amsterdam • Bonn
`Sydney • Singapore • Tokyo • Madrid • San Juan
`
`Petitioner Apple Inc. - Exhibit 1040, p. iii
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`Library of Congress Cataloging-in-Publication Data
`Reid, Glenn C.
`Thinking in PostScript / Glenn C. Reid.
` p. cm.
`Includes indexes.
`ISBN 0-201-52372-8
`1. PostScript (Computer program language) I. Title.
`QA76.73.P67R46 1990
`005.26’2—dc20
`
`90-43721
` CIP
`
`Copyright © 1990 by Glenn C. Reid
`
`All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
`transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise,
`without the prior written permission of the publisher. Printed in the United States of America. Published
`simultaneously in Canada.
`
`Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
`trademarks. Where those designations appear in this book and Addison-Wesley was aware of a trademark
`claim, the designations have been printed in initial capital letters.
`
`PostScript® is a registered trademark of Adobe Systems Incorporated (Adobe). All instances
`
`The name
`
`PostScript in the text are references to the PostScript language as defined by Adobe unless
`of the name
`
`PostScript also is used as a product trademark for Adobe’s implementation of
`otherwise stated. The name
`the PostScript language interpreter.
`
`Any references to a PostScript printer, a PostScript file, or a PostScript driver refer to printers, files, and
`driver programs (respectively) that are written in or that support the PostScript language.
`
`Sponsoring Editor: Carole McClendon
`Technical Reviewer: Ken Anderson
`Cover Design: Doliber Skeffington
`Text Design: Rex Holmes
`Set in 10-Point Times Roman
`
`ABCDEFGHIJ-MW-943210
`First printing, September, 1990
`
`Petitioner Apple Inc. - Exhibit 1040, p. iv
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`Table of Contents
`
`Preface......................................................................... xi
`
`Chapter 1
`PostScript as a Programming Language .................. 1
`DESIGN FEATURES............................................................................2
`
`STRUCTURED PROGRAMMING TECHNIQUES ...............................3
`
`PROGRAMMING TASKS.....................................................................4
`
`WINDOW SYSTEMS, COMMUNICATIONS, AND DISPLAYS............4
`
`DATA STRUCTURES AND ALGORITHMS .........................................6
`
`CONCLUDING THOUGHTS ................................................................6
`EXERCISES .............................................................................. 7
`
`Chapter 2
`PostScript is Not Like C.............................................. 9
`COMPARISON OF LANGUAGE MECHANISMS...............................11
`
`EXPRESSING AN ALGORITHM AS A PROGRAM ...........................12
`
`THE UNIX SHELL AND OPERATING SYSTEM................................13
`
`INPUT, OUTPUT, AND THROUGHPUT ............................................14
`
`v
`
`Petitioner Apple Inc. - Exhibit 1040, p. v
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`CONCLUDING THOUGHTS ..............................................................15
`EXERCISES............................................................................. 16
`
`Chapter 3
`Foundations............................................................... 17
`POSTSCRIPT LANGUAGE SYNTAX ................................................19
`
`SIMPLE PROGRAM STRUCTURE....................................................20
`
`SETTING UP TEMPLATES................................................................24
`
`DECLARING AND USING VARIABLES.............................................26
`
`ALLOCATING MEMORY....................................................................29
`
`GETTING MEMORY BACK................................................................31
`
`OPENING AND CLOSING FILES ......................................................31
`
`COMPARISONS AND EQUALITY OF OBJECTS..............................32
`
`CONCLUDING THOUGHTS ..............................................................34
`EXERCISES............................................................................. 34
`
`Chapter 4
`Some Typical Programs ........................................... 37
`A TYPICAL PAGE DESCRIPTION PROGRAM .................................38
`
`FONT PROGRAMS............................................................................40
`
`PROGRAMS THAT READ DATA.......................................................42
`
`QUERY PROGRAMS.........................................................................43
`
`ENCAPSULATED POSTSCRIPT PROGRAMS.................................43
`
`PERSISTENTLY RESIDENT PROGRAMS .......................................46
`
`CONCLUDING THOUGHTS ..............................................................49
`EXERCISES............................................................................. 49
`
`Chapter 5
`Understanding the Stack.......................................... 51
`A QUICK OVERVIEW OF DATA TYPES ...........................................51
`
`vi
`
`Table of Contents
`
`Petitioner Apple Inc. - Exhibit 1040, p. vi
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`NAME LOOKUP .................................................................................53
`
`HOW OPERATORS USE THE STACK..............................................53
`
`GROUPING AND VISUAL CHUNKING .............................................56
`
`THINKING BACKWARD AND SIDEWAYS ........................................58
`
`COMPOSITE OBJECTS ....................................................................61
`
`THE OTHER STACKS .......................................................................62
`
`CONCLUDING THOUGHTS ..............................................................63
`EXERCISES ............................................................................ 64
`
`Chapter 6
`Trusting the Stack ..................................................... 67
`SAFETY OF DATA ON THE STACK .................................................68
`
`WHERE ARE THE DATA GOING? ....................................................69
`
`REARRANGING THE STACK............................................................71
`
`CONDITIONALS AND LOOPS...........................................................73
`
`RECURSION AND LOCAL VARIABLES............................................76
`
`CONCLUDING THOUGHTS ..............................................................77
`EXERCISES ............................................................................ 78
`
`Chapter 7
`Building Conditional Statements ............................. 79
`SIMPLE CONDITIONALS ..................................................................80
`
`SETTING UP THE CONDITION.........................................................81
`
`CONDITIONALS ARE NOT MAGIC...................................................86
`
`NESTED CONDITIONALS AND ELSE CLAUSES ............................87
`
`COMPOUND CONDITIONALS ..........................................................88
`
`CONCLUDING THOUGHTS ..............................................................90
`EXERCISES ............................................................................ 91
`
`Table of Contents
`
`vii
`
`Petitioner Apple Inc. - Exhibit 1040, p. vii
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`Chapter 8
`Using Looping Constructs ....................................... 93
`LOOP BASICS ...................................................................................94
`
`USING THE LOOP INDEX .................................................................95
`
`LOOPS ARE PROCEDURE BODIES ................................................99
`
`LOOPS OF INSTRUCTIONS ...........................................................101
`
`EXITING LOOPS PREMATURELY..................................................102
`
`CONCLUDING THOUGHTS ............................................................103
`EXERCISES........................................................................... 103
`
`Chapter 9
`Procedures .............................................................. 105
`WHAT EXACTLY IS A PROCEDURE?............................................106
`
`PARAMETER PASSING ..................................................................108
`
`CONSTRUCTING GOOD PROCEDURES ......................................111
`
`SELF-MODIFYING PROCEDURES.................................................114
`
`CONCLUDING THOUGHTS ............................................................116
`EXERCISES........................................................................... 117
`
`Chapter 10
`Using Dictionaries................................................... 119
`DICTIONARIES FOR NAME SCOPING ..........................................120
`
`LOCAL DICTIONARIES ...................................................................121
`
`GLOBAL DICTIONARIES OF PROCEDURES ................................123
`
`MAINTAINING THE DICTIONARY STACK......................................124
`
`INTO AND OUT OF DICTIONARIES ...............................................126
`
`LOOKING INTO DICTIONARIES .....................................................127
`
`REDEFINING OPERATORS............................................................130
`
`CONCLUDING THOUGHTS ............................................................132
`EXERCISES........................................................................... 133
`
`viii
`
`Table of Contents
`
`Petitioner Apple Inc. - Exhibit 1040, p. viii
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`Chapter 11
`Creating and Manipulating Data............................. 135
`CONSTRUCTING AN ARRAY .........................................................135
`
`CONSTRUCTING A STRING...........................................................137
`
`MANIPULATING DATA WITH PUT AND GET.................................137
`
`CONCATENATING ARRAYS AND STRINGS .................................139
`
`INPUT AND OUTPUT OF STRING DATA .......................................140
`
`ARRAYS VERSUS DICTIONARIES ................................................141
`
`ADVANCED TECHNIQUES .............................................................142
`
`CONCLUDING THOUGHTS ............................................................143
`EXERCISES .......................................................................... 144
`
`Chapter 12
`Storing and Using Data........................................... 145
`CLASSICAL DATA STRUCTURES..................................................151
`
`CONCLUDING THOUGHTS ............................................................156
`EXERCISES .......................................................................... 156
`
`Chapter 13
`Program Data and Instructions .............................. 157
`TURNING DATA INTO INSTRUCTIONS .........................................159
`
`TURNING INSTRUCTIONS INTO DATA .........................................161
`
`DATA CONVERSIONS ....................................................................163
`
`CONCLUDING THOUGHTS ............................................................165
`EXERCISES .......................................................................... 165
`
`Chapter 14
`Using Files and Input/Output Techniques ............ 167
`OPENING AND CLOSING FILES ....................................................170
`
`READING AND WRITING FILES .....................................................172
`
`Table of Contents
`
`ix
`
`Petitioner Apple Inc. - Exhibit 1040, p. ix
`
`

`
`
`
`
`
`
`
`WRITING FORMATTED DATA TO FILES .......................................175
`
`FILE STATUS INFORMATION.........................................................178
`
`RANDOM VERSUS SEQUENTIAL ACCESS ..................................179
`
`CONCLUDING THOUGHTS ............................................................180
`EXERCISES........................................................................... 180
`
`Appendix
`Answers to Exercises ............................................. 185
`
`Index of Example Programs ................................... 209
`
`Subject Index ........................................................... 217
`
`x
`
`Table of Contents
`
`Petitioner Apple Inc. - Exhibit 1040, p. x
`
`

`
`
`
`
`
`
`Preface
`
`This book is intended to provide a practical, intriguing, and fresh look at
`the PostScript programming language. PostScript is a mysterious
`language, powerful and cryptic. It is expressive and complicated and yet
`surprisingly simple. In order to master a programming language, you have
`to learn to think like the compiler or interpreter, and instinctively know
`how to solve problems. You develop a “tool kit” of useful approaches,
`proven solutions, and techniques. You reach an understanding that is
`based on analogy and connections with other things that you know.
`
`This book helps you build a solid foundation of understanding for the
`PostScript language. It teaches you to become an expert programmer and
`to have confidence that you have written the best possible PostScript
`program. It shows you how to combine the elements of the language into
`a strong, well-designed, modular program that is easy to develop and
`maintain. It is not a problem-solving book, nor simply a reference to the
`language; it is a guide to developing programming techniques and to
`learning how to use the PostScript tool kit, which is filled with hundreds
`of individual operators.
`
`Comparisons are drawn to other programming languages throughout the
`book, particularly to C, which is a very common language and one that is
`often used in the same environments where the PostScript language is
`found. If you are a competent C or Pascal programmer but you have had
`limited exposure to PostScript, this book should be exactly what you
`need. If you are a BASIC, Forth, or Lisp programmer, you should find
`this book at just the right level for introducing you to the PostScript
`
`xi
`
`Petitioner Apple Inc. - Exhibit 1040, p. xi
`
`

`
`
`
`
`
`
`
`
`language. If you think of yourself as an expert PostScript programmer,
`you will still find some useful techniques in this book, and it is a very
`worthwhile addition to your library of PostScript books, since it overlaps
`very little with existing material.
`
`The most fundamental level of a program is the set of techniques used in
`the development of the program itself, regardless of what the program
`does. This book addresses that area of PostScript programming in a way
`rooted partly in computer science theory, encompassing algorithms and
`data structures, but it is very practically oriented toward real-world
`programming and programmers.
`
`Each chapter contains a section of Exercises. You should find these
`problems easy to solve if you have understood the concepts in the chapter.
`Many concepts do not gel fully without some direct application to a
`problem. In these cases, the exercises should stimulate you to think about
`the issues that have been presented and give you a chance to confront a
`situation that requires you to apply your knowledge. The appendix
`contains answers to the exercises.
`
`To give you a feel for what this book is about and to whet your appetite,
`the following code segment illustrates a common (though advanced)
`technique that is used in many PostScript programs. If you instantly
`recognize what it does and could have written it yourself, then you may
`use this book to discover other techniques that you may not have yet
`encountered. If this example seems mysterious or you have to spend a lot
`of time analyzing it, then you need this book to help you start thinking this
`way.
`
`% print out all the elements in an array or procedure
`dup type /arraytype eq 1 index type /packedarraytype eq or { %ifelse
`0 exch { %forall
`exch dup (XXX) cvs print (: ) print 1 add exch ==
`} forall pop
`}{ pop } ifelse
`
`This particular example is a bit advanced and special-purpose, but it
`should not be intimidating even to a beginning or intermediate
`programmer. A typical question in an end-of-chapter exercise might be
`“Rewrite the previous program fragment using local variables rather than
`using the operand stack.”
`
`xii
`
`Preface
`
`Petitioner Apple Inc. - Exhibit 1040, p. xii
`
`

`
`
`
`
`
`In order to get the maximum benefit from this book, you probably should
`have written at least one program—from scratch—longer than 100 lines
`of code (and gotten it to work correctly). This program might have been
`written in virtually any programming language. If you then modified the
`program for an additional 100 hours after it first started to work, if you
`understand variables, arrays, and strings—and if you want to become a
`very good PostScript programmer—then you are an ideal candidate for
`this book.
`
`Preface
`
`xiii
`
`Petitioner Apple Inc. - Exhibit 1040, p. xiii
`
`

`
`
`
`xiv
`
`Preface
`
`Petitioner Apple Inc. - Exhibit 1040, p. xiv
`
`

`
`
`
`
`
`
`
`Chapter 1
`
`PostScript as a
`Programming Language
`
`It probably is true that PostScript is not everyone’s first choice as a
`programming language. But let’s put that premise behind us, and assume
`that you need (or want) to write a program in the PostScript language.
`How do you become an expert in this language, and how do you develop
`the instincts and learn the techniques necessary to tackle challenging
`problems with confidence?
`
`As a programming language, PostScript is somewhat unusual—and
`frankly, many of the programming instincts you’ve developed from using
`other languages may not be directly applicable with the PostScript
`language. The first few chapters of this book help you put PostScript into
`perspective by comparing it to languages you probably already know,
`such as C. There are stronger similarities between PostScript and, say,
`Forth or Lisp, but if you are expert in either of those languages you
`probably won’t have much trouble mastering PostScript.
`
`1
`
`Petitioner Apple Inc. - Exhibit 1040, p. 1
`
`

`
`
`
`
`
`
`
`
`Every programming language was designed with a specific purpose, even
`if that purpose was to be a “general-purpose programming language.” To
`use a language effectively, you should understand its design and learn its
`strengths and weaknesses. PostScript is a full-fledged programming
`language, and it is possible to accomplish almost any task with it. It
`includes many high-level language constructs and data structures. The
`PostScript language is a tool kit filled with hundreds of special-purpose
`tools. Mastery of the language teaches you to select just the right
`instrument, swiftly and instinctively, and to use it effectively.
`
`DESIGN FEATURES
`
`PostScript’s most obvious language features are that it is an interpreted
`language, it is stack-based, and it is heavily oriented toward graphics and
`typography. These design choices were all made in order to make it useful
`as a device-independent page description language for imaging on raster
`devices. These language features also make it a fairly unusual language in
`which to write programs.
`
`The PostScript language is stack-based (resulting in “backwards” syntax)
`primarily so that a program can be evaluated with very low overhead in
`processing and storage. Each instruction can be acted upon immediately,
`without the need to buffer large amounts of the program.
`
`PostScript is interpreted (rather than compiled) for a couple of reasons.
`The most obvious one is device independence. If the program remains in
`source form until it reaches its final destination, it is extremely portable to
`new computer environments, processors, etc. It is an interpreted language
`also because documents are often transmitted long distances, archived, or
`saved and printed many times, and this enables the documents to remain
`in ASCII text source form for better life expectancy and resiliency in a
`device-independent environment.
`
`And finally, PostScript is heavily biased toward graphic imaging and
`typography because it was originally conceived as a mechanism to control
`raster imaging devices like laser printers and display screens.
`
`The design choices made in the PostScript language have quite an impact
`on the programmer’s experiences in mastering the language, but they
`
`2
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`Petitioner Apple Inc. - Exhibit 1040, p. 2
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`were not made arbitrarily, nor intended to make the programmer’s life
`more difficult.
`
`STRUCTURED PROGRAMMING TECHNIQUES
`
`If you have had any formal training in programming, you are familiar
`with the various structured programming techniques, up through and
`including object-oriented programming. These techniques vary, but are
`largely based on the concept of a procedure, or a modular functional unit
`
`black box). A black box is typically any set of
`(sometimes called a
`operations that has a specific input and output and performs a single task.
`The mechanics of the operation are hidden from one who uses the black
`box. This is the notion behind writing procedures, creating software
`libraries, object-oriented programming, block-structured code; it is a
`widely recognized technique in computer science.
`
`to structured
`isn’t well suited
`To start out, PostScript simply
`programming, and if you try too hard to formalize the interfaces, declare
`local variables, and observe many tried and true programming practices,
`you may end up with a complicated, inefficient, and ill-designed program.
`On the other hand, if you ignore structured programming techniques and
`write code off the top of your head, you will probably have something
`worse. The trick is to borrow enough of the useful concepts from
`structured programming to make programs readable, easy to maintain,
`easily debugged, and efficient, while using the expressive power of the
`language to your advantage.
`
`goto
` in the PostScript language, or even explicit
`There is no concept of
`control transfer, so you don’t have to worry about that particular dogmatic
`concern. You do have to be careful about procedure-calling interfaces,
`where they exist, since all program checking is done at run-time.
`
`Many of the concepts in structured programming can be used quite
`effectively in PostScript. You can define procedures to help you share
`similar code across parts of your program. You can use the operand stack
`for your temporary data rather than having many global variables. You
`can design interfaces between components of your program and pass
`parametric information on the stack. You can even define functions that
`return results onto the stack for use by other procedures.
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`3
`
`Petitioner Apple Inc. - Exhibit 1040, p. 3
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`PROGRAMMING TASKS
`
`There are many different kinds of tasks associated with programming.
`There are data-crunching tasks, user interface tasks, communication with
`other computers or programs, file operations, graphics, and various
`others. In some tasks, such as numerical computation, the algorithm by
`which the task is carried out is of the utmost importance, both for
`accuracy and for performance. Other tasks, such as user interfaces and
`graphics, are much more results oriented: what is important is whether it
`looks good and/or works well. In file operations, arguably the accuracy
`with which the operations are carried out is the most important aspect of
`the task, and the algorithm and performance of the task are secondary.
`
`The nature of the task has a strong influence on the programming style
`and technique. If your purpose is to draw graphics, your programming
`efforts should be minimal, clear, and used only to streamline the process
`of drawing. In
`the PostScript
`language
`in particular, graphics
`programming is the means to the end, not the end in itself. The
`PostScript
` mentions that any marks made on the page
`Language Reference Manual
`are a side effect of the execution of the program, but from your
`perspective as a programmer, it is the other way around. The fact that you
`have to write PostScript programs is a side effect of the fact that you are
`trying to draw pictures on a PostScript-based system.
`
`WINDOW SYSTEMS, COMMUNICATIONS, AND DISPLAYS
`
`Recently, the PostScript language has evolved from a printer control
`language into a communications medium on host computers. There are
`window systems and networks based on the PostScript language. In light
`of this, there are many new kinds of programming tasks that must be (or
`can be) carried out in the PostScript language.
`
`interesting aspects of a window system or
`the more
`One of
`communications environment based on a programming language is that
`you can send an algorithmic description of the picture you want drawn (or
`of the operation you want carried out) instead of the individual bits or
`instructions. For instance, if you wanted to draw a grid of parallel lines,
`both horizontally and vertically, you might express this graphic operation
`
`4
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`Petitioner Apple Inc. - Exhibit 1040, p. 4
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`(which has a strongly repetitive basis) as two loops of instructions. (See
`Example 1.1. The results of Example 1.1 are shown in Figure 1.1).
`
`Example 1.1: Repetitive Algorithms
`
`% 18-pt spacing, 24 lines
`0 18 18 24 mul { %for
`dup 0 moveto
`600 lineto
`} for stroke
`
`% 18-pt spacing, 36 lines
`0 18 18 36 mul { %for
`dup 0 exch moveto
`436 exch lineto
`} for stroke
`
`Figure 1.1: Output of Example 1.1
`
`This is quite a bit more compact than it would be to draw 60 individual
`
`moveto and
`
`lineto instructions.
`lines, each with its own coordinates and
`0
`; just
`In this particular example, 25 percent of the data end up being
`avoiding the transmission of those zeroes is significant. The loops above
`consist of 30 PostScript language tokens to be transmitted, whereas the
`
`moveto and
`
`lineto instructions would require
`same program done with
`360 PostScript tokens.
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`5
`
`Petitioner Apple Inc. - Exhibit 1040, p. 5
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`In addition to providing power and compactness of representation, having
`an interpreted programming language at the network and graphics layer of
`a computer system provides a very neat solution to problems of
`transportability and machine independence, since many of the decisions
`are delayed until run-time. One important concept in object-oriented
`programming in general is to keep the interface between objects clean
`enough that there are not any problems when you hook them together.
`This is especially important where you have to write programs at the
`places where objects meet. It is important for you, the reader and
`programmer, to understand PostScript well enough to create programs
`that behave well in the nested, shared, cut-and-pasted environments that
`exist today.
`
`DATA STRUCTURES AND ALGORITHMS
`
`The classic view of a computer program is a synthesis of data structures
`and algorithms. Books often have titles that contain these two words, and
`every program probably has one or the other in it somewhere. If you use
`PostScript to describe pages and to drive laser printers, your need for real
`data storage and computation should be minimal. However, if you use
`PostScript in a windowing environment to arbitrate input events from the
`keyboard (as an extreme example), you will definitely need to create data
`structures and implement some potentially difficult algorithms.
`
`CONCLUDING THOUGHTS
`
`The next several chapters help you build some solid approaches to
`PostScript data structures and help you master the language elements
`thoroughly so that you will feel comfortable implementing your favorite
`algorithms. In particular, the data types unique to PostScript are explored
`(dictionaries and names) as well as traditional data types such as strings,
`arrays, and numbers. Other chapters are devoted entirely to seemingly
`
`ifelse operator or looping. However, since
`simple things like the
`PostScript was not originally designed for heavy programming, these
`traditional programming
`techniques have never been
`thoroughly
`addressed. And you simply can’t write a serious PostScript program
`
`ifelse or writing a procedure or two.
`without using
`
`6
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`Petitioner Apple Inc. - Exhibit 1040, p. 6
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`EXERCISES
`
`Each chapter in this book comes with some exercises at the end of it, to
`help you to test your understanding of the concepts presented. Since this
`first chapter has taken a philosophical overview of PostScript as a
`programming language, the exercises are more like essay questions than
`problems.
`
`1.
`
`2.
`
`3.
`
`4.
`
`Why do you want to write a PostScript program? (This is a serious
`question, and one which should be given some thought; reflection on
`
`why may provide you with good horse sense throughout your pro-
`gramming experience.)
`
`Why is PostScript a “backwards” language, in which the operators
`
`after the operands?
`come
`
`Why is PostScript an interpreted language?
`
`Why is it silly to write fractal programs in PostScript?
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`7
`
`Petitioner Apple Inc. - Exhibit 1040, p. 7
`
`

`
`
`
`8
`
`Chapter 1: POSTSCRIPT AS A PROGRAMMING LANGUAGE
`
`Petitioner Apple Inc. - Exhibit 1040, p. 8
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`Chapter 2
`
`PostScript is Not Like C
`
`Many programmers try to treat a new language as if it were an old
`language with which they are already familiar. “If you know one
`programming language, you know them all.” That is somewhat true with
`procedural languages like C, Pascal, Modula 3, or maybe FORTRAN.
`
`if ...
`then
`
`else, and once you learn
` ...
`There are only so many ways to say
`one language, you can learn the others without too much difficulty. These
`languages typically only have a dozen or so language elements; if you
`were to name all the “reserved words” in Pascal or C, how many would
`you come up with? If you named the built-in features of the language, you
`wouldn’t get much past control structures, procedure definitions, data
`types, and input/output capabilities. These languages are general-purpose
`procedural languages.
`
`But PostScript has over 300 individual special-purpose operators, it is
`interpreted rather than compiled, it uses post-fix notation, and is quite
`different from C. This is good, to a large extent, but again, you need to
`
`9
`
`Petitioner Apple Inc. - Exhibit 1040, p. 9
`
`

`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`understand the differences rather than to take the posture that it’s just
`another language.
`
`In a procedural language, the interface between components of a program
`is formalized in the notion of a procedure call. (For more information
`about procedures, see Chapter 9). The program is typically written as a
`series of modular procedures or functions, with a well-defined calling
`mechanism for transferring control and passing data between the
`modules. This calling mechanism is artificial, and is apparent only at the
`programming language level. When compiled, the data (or pointers to the
`data) are in fact placed on the operand stack of the hardware processor,
`and an instruction to jump to a subroutine (JSR) is issued to transfer
`control to the other procedure, which then uses the data on the stack. The
`notion of type checking is carried out at the language level by requiring
`that the data be declared to be of an explicit type as the data are being
`passed to or from a procedure or function.
`
`When writing C programs, the programmer designs the modules, the
`interfaces, and the interaction between them. The data structures are
`designed to work cleanly within the modular design of the program, and
`the parameters to the various procedures are set up to pass data
`appropriately between the modules or procedures. Data types and
`structures should be appropriate for the task at hand; some of them are
`
`globally visible (and therefore can be used throughout the entire
`made
`
`local to a particular procedure (and can be used only
`program); others are
`within that procedure). A fairly high percentage of coding time is spent
`just selecting names for data types, structure elements, procedures,
`variables, and modules. The names given to these program elements
`contribute heavily to the readability and maintainability of the code.
`
`The PostScript language is an interesting hybrid between high-level and
`low-level languages. It is high level in the sense that there are individual
`show
` operator,
`operators that encom

This document is available on Docket Alarm but you must sign up to view it.


Or .

Accessing this document will incur an additional charge of $.

After purchase, you can access this document again without charge.

Accept $ Charge
throbber

Still Working On It

This document is taking longer than usual to download. This can happen if we need to contact the court directly to obtain the document and their servers are running slowly.

Give it another minute or two to complete, and then try the refresh button.

throbber

A few More Minutes ... Still Working

It can take up to 5 minutes for us to download a document if the court servers are running slowly.

Thank you for your continued patience.

This document could not be displayed.

We could not find this document within its docket. Please go back to the docket page and check the link. If that does not work, go back to the docket and refresh it to pull the newest information.

Your account does not support viewing this document.

You need a Paid Account to view this document. Click here to change your account type.

Your account does not support viewing this document.

Set your membership status to view this document.

With a Docket Alarm membership, you'll get a whole lot more, including:

  • Up-to-date information for this case.
  • Email alerts whenever there is an update.
  • Full text search for other cases.
  • Get email alerts whenever a new case matches your search.

Become a Member

One Moment Please

The filing “” is large (MB) and is being downloaded.

Please refresh this page in a few minutes to see if the filing has been downloaded. The filing will also be emailed to you when the download completes.

Your document is on its way!

If you do not receive the document in five minutes, contact support at support@docketalarm.com.

Sealed Document

We are unable to display this document, it may be under a court ordered seal.

If you have proper credentials to access the file, you may proceed directly to the court's system using your government issued username and password.


Access Government Site

We are redirecting you
to a mobile optimized page.





Document Unreadable or Corrupt

Refresh this Document
Go to the Docket

We are unable to display this document.

Refresh this Document
Go to the Docket