Apple 310 manual Packed Arrays Versus Ordinary Arrays, Creating Packed Arrays

Page 52

C H A P T E R 2

LaserWriter Select 310 Software

Packed Arrays

PostScript language procedures are represented as executable arrays, which were previously stored in the same fashion as literal data arrays. This type of representation offers maximum flexibility but is very costly in terms of space, requiring 8 bytes per element. Large PostScript Language programs, such as the built-in server program, and downloaded preambles, consume considerable amounts of virtual memory.

Programs do not require the ability to be treated as data, but only the ability to be executed. The packed array fulfils this requirement. Programs represented as packed arrays are typically 50% to 70% smaller than programs represented as ordinary arrays.

Packed Arrays Versus Ordinary Arrays

The packed array object has a type different from an ordinary array, using packedarraytype instead of arraytype. However, in most respects it behaves in the same way. You can

extract elements using get

extract subarrays using getinterval

enumerate the array using forall

Individual elements extracted from a packed array are ordinary PostScript language objects. A sub-array of a packed array is also a packed array.

Packed arrays are different from ordinary arrays in the following ways:

packed arrays are always read only; you cannot use put or putinterval to store into one

packed arrays are created differently; (see the section below, “Creating Packed Arrays”)

accessing arbitrary elements of a packed array can be quite a slow process; however, accessing elements sequentially, as the PostScript interpreter and the forall operator do, is almost as efficient as accessing an ordinary array

the copy operator cannot copy into a packed array, since the array is read only. However, it can copy the value of a packed array to an ordinary array that is at least as long as the packed array

Creating Packed Arrays

Packed arrays may be created in two ways. The first and more common way is for the PostScript interpreter’s input scanner to create packed arrays automatically for all executable arrays that it reads. This means that whenever the scanner encounters a { while reading a file or string, it accumulates all tokens up to the matching } and turns them into a packed array instead of an ordinary array.

The choice of array type is controlled by a mode setting, manipulated by the new operators, setpacking and currentpacking. (See “Setting Extensions to PostScript Level 1,” earlier in this chapter.) If the array packing mode is true, PostScript language procedures encountered subsequently by the scanner are created as packed arrays. If the mode is false, procedures are created as ordinary arrays. The default value is false to preserve compatibility with existing programs.

40

PostScript Language Changes

Image 52
Contents Apple LaserWriter Select 310 Printer Limited Warranty on Media and Replacement Contents Page Communication Channels Page Figures and Tables Page About This Note What This Note ContainsConventions Used in This Note Other Reference MaterialFor More Information ApdaPage LaserWriter Select Hardware1 LaserWriter Select 310 Hardware ROM Communication Ports Serial Port for RS-232C DevicesCentronics Parallel Connector 2An 8-pin serial port connectorPstrobe Signal Status Lights Memory Capabilities ROM CapabilityBasic Operation Batch ModeDram Expansion Interactive Mode TypesPaper Handling 7Paper handling options Page LaserWriter Select 310 Software Adobe PostScript Programming Language Software OverviewPostScript Interpreter LaserWriter Select 310 Driver TypesSelects the paper tray containing A4-size paper and sets Software Parameters Product StringsCommunication Device Parameters Compatibility OperatorsStatusdict Setting Compatibility Operators Device Setting System Parameters CheckpasswordDefaulttimeouts IdlefontsPrintername ProductProductA RamsizeSetpassword SetdefaulttimeoutsSetidlefonts Setting Page Device Parameters DefaultmultipurposetraysizeDefaultpapertray SetprinternameManualfeedtimeout ManualfeedMargins PagestackorderPapersize SetdefaultmultipurposepapertraysizePapertray Setdostartpage SetdefaultpapertraySetmargins Setpagetype SetpagestackorderSetpapertray Setting User Parameters JobtimeoutSetjobtimeout JobnameWaittimeout Setting Device ParametersSetsoftwareiomode Softwareiomode Setting Communication ParametersPacketbackchannel Sccbatch SetpacketbackchannelSetsccbatch Setting Engine Device ParametersDarkness Setting Extensions to PostScript Level SetdarknessCurrentcacheparams CurrentpackingPackedarray SetcacheparamsPrinter Error Parameter SetpackingPrintererror PostScript Language ChangesPacked Arrays Versus Ordinary Arrays Packed ArraysCreating Packed Arrays Immediately Evaluated Names Device Resolution Images Changes in Font Cache OperationEnd-of-Line Recognition TrueType Fonts New OperatorsCommunication Channels Serial Communication Baud RatesFlow Control Parity SettingsDTR Flow Control SCC Operator Encoding XON/XOFF Flow ControlCommunication Protocols Simple Communication ProtocolBinary Communication Protocol SOH CTL-A Communicating with an IBM PC Parallel InterfaceSerial Interface DTR Flow Control for PC CommunicationCommunication Dynamics XON/XOFF Flow Control for PC CommunicationStatus Queries and Spontaneous Messages Errorerror OffendingCommand operator %%