BLISS: A Language for Systems Programming

W.A. Wulf, D.B. Russell, A.N. Hab ermann

Carnegie-Mellon University

A language, BLISS, is describ ed. This language is designed so as to b e esp ecially suitable for use in

writing pro duction software systems for a sp eci machine (the PDP-10): , op erating systems,

etc. Prime design goals of the design are the abilitytopro duce highly ecient object co de, to allow

access to all relevant hardware features of the host machine, and to provide a rational means by which

to cop e with the evolutionary nature of systems programs. A major feature which contributes to the

realization of these goals is a mechanism p ermitting the de nition of the representation of all data

structures in terms of the access algorithm for elements of the structure.

sp eci c machine. Sp ecial purp ose languages, such Intro duction

as -compilers, do not fall into this category,

nor do we necessarily assume that these languages In the fall of 1969, Carnegie-Mellon University

need b e machine-indep endent. We stress the word acquired a pdp-10 to supp ort a research pro ject

\implementation" in our de nition and havenot on networks. This researchinvolves

used words such as \design" and \do cumentation." the pro duction of a substantial numb er of large

We do not necessarily exp ect that an implemen- systems programs of the typ e whichhave usually

tation language will b e an appropriate vehicle for b een written in . Atanearly

expressing the initial design of a large system nor stage of this design e ort it was decided not to

for the exclusive do cumentation of that system. use assembly language, but rather some higher-level

Concepts suchasmachine indep endence, expressing language. This decision immediately led to another

the design and implementation in the same notation, question|which language? In turn this led to a

self-do cumentation, and others, are clearly desirable consideration of the characteristics, if any,which are

goals and are criteria by whichweevaluated various unique to, or at least exaggerated in, the pro duction

languages. and maintenance of systems programs. One pro duct

However, they are not implicit in our de nition. of these delib erations was a new language, whichwe

There are a few extant examples of languages which call bliss. Clearly, a language is not the only to ol

our de nition: epl (a PL/1 derivative which needed; however, it is the one with whichwedealin

was initially used on multics [1] but whichhas this pap er.

b een replaced by full PL/1), B5500 Extended We refer to bliss as an \implementation lan-

(Burroughs Corp oration [2]), PL360 [3], and bcpl guage," although we admit that the term is some-

[4]. what ambiguous since, presumably, all computer

The various arguments for and against the use languages are used to implement something. To

of higher-level languages to write systems software us the phrase connotes a general purp ose, higher-

have b een discussed at length. We do not intend to level language in which the primary emphasis has

repro duce them here in detail except to note that the b een placed up on a sp eci c application, namely the

skeptics argue primarily on two grounds: eciency, writing of large, production software systems for a

and an assertion that the systems must

C

Copyright 1971, Asso ciation for Computing Machinery,

not allowanything to get b etween himself and the

Inc. Reprinted from the Decemb er 1971 issue of Communi-

machine. The advo cates argue on the grounds of

cations of the ACM (Volume 14, Number 12). Permission to

pro duction sp eed (and cost), maintainability,re-

reprint granted by the Asso ciation for Computing Machinery.

design and mo di cation, and understandability and 1

 ob ject co de must not dep end up on elab orate correctness. The rep ort of the NATO Conference

run-time supp ort on Software Engineering held in Garmish (Octo-

b er 1968) [5] contains several discussions on these

Characteristics of Systems Programming Practice p oints.

 control over the representation of data structures It is our opinion that program eciency, except

 exible range of control structures (notably in- p ossibly for a very small number of very small co de

cluding recursion, , and asynchronous segments, is determined byoverall program design

pro cesses) and not by lo cally tricky, \bit-picking" co ding prac-

 mo dularization of a system into separately com- tices. Moreover, the critical co de segments are

pilable submo dules frequently lo cated only after the system is op era-

 parameterization, esp ecially conditional compi- tional. This opinion is b orne out bymany systems

lation whichhave exp erienced substantial p erformance im-

provements from redesign or restructuring result-

Overal l GoodLanguage Design ing from understanding or insight after the system

 encourages program structuring for understand- has b een running for some time (see, for example,

ability E.E. David's comments, [5, pp. 55{57]). One of the

 encourages program structuring for paramount design ob jectives of bliss was to facili-

and measurement tate redesign and reco ding. Since this redesign is fre-

 economy of concepts (involution), generality, quently done by someone other than the program's

exibility, etc. original author, there is a corollary ob jectiveof

 utility as a design to ol readability. This argues for go o d do cumentation|

 machine indep endence but also for understandability of the co de itself.

Understandability is a function of many things, not

The order in the ab ove list is not accidental. Those all of which are inherent in the language in which

items found early in the list we consider to b e a program is written|a programmer's individual

absolute requirements, while those o ccurring later in style, for example. Nevertheless, the length of a

the list may b e thoughtofascriteriaby which alter- program text and the structure imp osed up on that

native designs are judged once the more demanding text are imp ortant factors and argue strongly for the

requirements are satis ed. use of a higher-level language.

Not all of the goals mentioned ab ove are com- Presuming the decision to use an implementa-

patible in practice. For example, eciency, access tion language, which one should one cho ose? An

to machine features, and machine indep endence are argument might b e made for cho osing one of the

con icting goals. In fact, the design of bliss is existing languages, say fortran, PL/1, or apl,

not machine indep endent, although the underlying and p ossibly extending it in some way. Wehave

philosophy and much of the sp eci c design are. The chosen to add to the tongues of Bab el by de ning

machine for which the language was b eing designed, yet another new language, and some justi cation is

the pdp-10,was constantly in the minds of the de- required. The only valid rationale for creating a new

signers. The co de to b e generated for each prop osed language is that the existing ones are inappropriate

construct, or form of a construct, was considered to the task. It was our judgement that no existing

b efore that construct was included in, or excluded languages dealt with all of the prop er issues and

from, the language. Thus the characteristics of the hence a new language was necessary. What then are

target machine p ervade the language in b oth overt the sp ecial characteristics of systems programs for

and subtle ways. This is not to say that bliss could which existing languages are inappropriate? (Later

not b e implemented for another machine; it could. we shall discuss how these manifest themselves in

It do es say that bliss is particularly well suited to bliss.) The two sp ecial characteristics most fre-

implementation on the pdp-10 and that it could quently mentioned are eciency and access to all

probably not b e as eciently implemented on most hardware features of the machine. We add several

other machines. We think of bliss as a member things to these; the resulting list forms the design

(the only one at present) of a class of languages ob jectives of bliss.

that are similar in philosophy and that mirror a

similar concern for the imp ortant asp ects of systems Requirements of Systems Programs

programming, but where each is tailored to its host  space/time economy

machine.  access to all relevant hardware features 2

As another example of the incompatibilityof control, and (3) data structures; nally,wemention

these goals, consider the requirement for minimal some other miscellaneous features.

run-time supp ort and the use of the implementation

language as a design to ol. In some sense a design 1. Storage

to ol should b e at a higher level than the ob ject A bliss program op erates with and on a number

b eing designed|that is, the to ol should relievethe of storage \segments." A storage segment consists

designer from concern over whichever details the of a xed and nite number of \words," eachof

designer deems appropriate only for later consider- which is comp osed of a xed and nite number of

ation. Any language relieves its user from concern \bits" (36 for the pdp-10). Anycontiguous set

over certain details; even assembly language frees of bits within a word is called a \ eld." A eld

the co der from the need to make sp eci c address may b e \named"; the valueofanameiscalled

assignments. Assembly language is not a go o d a\pointer" to that eld. In particular, an entire

design to ol, however, precisely b ecause the class of word is a eld and may b e named. In practice a

such facilities is small; a higher-level language is segment generally contains either program or data,

b etter b ecause the class is larger. There is a p oint, and if the latter, it is generally integer numb ers,

however, b eyond which broadening the class of de- oating-p ointnumb ers, characters, or p ointers to

tails which are handled automatically intro duces other data. Toa bliss program, however, a

substantial costs in run-time eciency and requisite eld merely contains a pattern of bits. Various

run-time supp ort. The design of bliss walks a very op erations may b e applied to elds and bit patterns,

ne line b etween generality, eciency, and minimal such as fetching a bit pattern (value) from a eld,

run-time supp ort. In fact, bliss programs require storing a bit pattern into a eld, integer arithmetic,

no run-time supp ort routines. comparison, Bo olean op erations, and so on. The

interpretation placed up on a particular bit pattern

Description of BLISS and the consequent transformation p erformed byan

op erator is an intrinsic prop erty ofthatoperatorand

bliss maybecharacterized as an \algol-PL/1" not of its op erands. That is to say, there is no \typ e"

derivative in the sense that it has a similar ex- di erentiation as in algol.

pression format and op erator hierarchy,ablock Segments are intro duced into a bliss program

structure with lexically and dynamically lo cal vari- by declarations, called \allo cation declarations," for

ables, similar conditional and lo oping constructs, example:

and (p otentially) recursive pro cedures. As maybe

global g ;

seen from the two simple examples shown b elow,

own x, y [5], z ;

the general format of bliss co de is quite algol-

lo cal p[100];

like; however, the similarity stops shortly b eyond

register r 1, r 2[3];

this glib comparison.

function f (a; b)=:a " :b;

function f actor ial (n)=

Each of these declarations intro duces one or more

if .n  1 then 1 else .n  f actor ial (:n 1);

segments and binds the identi ers mentioned (e.g. g ,

function QQ sear ch (K ) =

x, y ) to the name of the rst word of the asso ciated

b egin register R,Q,A,E ;

segment. (The function declaration also initializes

E R :K =:n; Q :K mod :n;

the segmentnamedf to the appropriate machine

A :const;

co de.)

do if :S T [:R]=:K

The segments intro duced by these declarations

then return :R

else (R :R + :A; A :A :Q) contain one or more words, where the size may

until :R = :E

b e sp eci ed (as in lo cal p[100]), defaulted to one

end;

(as in global g ;), or defaulted to whatever length

is necessary for initialization (as in the function

The rst of these examples is the familar recursive

declaration). The identi ers intro duced by a decla-

de nition of factorial. The second example is

ration are lexically lo cal to the blo ck in whichthe

the \quadratic quotient" hash search describ ed by

declaration is made (that is, they ob ey the usual

J. Bell [9].

algol scop e rules), with one exception|namely,

Wenow describ e the features of bliss in terms of

global identi ers are made available to other, sep-

its ma jor asp ects|(1) the underlying storage, (2)

arately compiled mo dules. Segments created by 3

ing function calls, for example). The authors feel own, global, and function declarations are created

strongly that this context-indep endentinterpreta- only once and are preserved for the duration of the

tion of identi ers simpli es systems programming. execution of a program. Segments created by lo cal

Exp erience in using the language for nontrivial pro- and register declarations are created at the time of

gramming tasks supp orts this p ointofview. blo ckentry and are preserved only for the duration

There are two additional declarations whose ef- of the execution of that blo ck. The register seg-

fect is to bind identi ers to names, but whichdo ments di er from lo cal segments only in that they

not create segments; examples are: are allo cated from the machine's array of 16 general

purp ose (fast) registers. Reentry of a blo ck b efore

external s;

it is exited (by recursive function calls, for example)

bind y 2=y +2, pa = p + :a;

b ehaves as in algol, that is, lo cal and register

segments are dynamically lo cal to each incarnation

An external declaration binds one or more identi ers

of the blo ck.

to the names represented by the same identi er

It is imp ortant to notice from the discussion

declared global in another, separately compiled

ab ove that identi ers are b ound to names bythese

mo dule. The bind declaration binds one or more

declarations, and that the value of a name is a

identi ers to the value of an expression at blo ck

p ointer. Thus the value of an instance of an

entry time. At least p otentially the value of this

identi er, say x,isnot the value of the eld

expression may not b e calculable until run time|as

named by x, but rather is a p ointer to x. This

in \pa = p + :a"above. Examples of the use of bind

interpretation requires a \contents of" op erator for

will b e found in subsequent sections.

which the symb ol \." has b een chosen. Toa

programmer who is used to the context-dep endent

2. Control

interpretation of identi ers, it may seem that the

bliss is an \expression language," that is, every

notations x and :x forapointer to a eld and value

executable construct, including those whichmani-

of that eld, resp ectively,might b etter b e replaced

fest control, is an expression and computes a value.

by@x and x.However, a little comparison will so on

There are no statements in the sense of algol

show that the dot notation is to b e preferred.

or PL/1. Expressions may b e concatenated with

First, \." has a unique interpretation as a unary

semicolons to form comp ound expressions, where

op erator meaning: \take the contents of the eld

the value of a comp ound expression is that of its last

p ointed at by x." @x cannot b e interpreted as the

comp onent expression. Thus \;" may b e thought

inverse of \.x", since the dot function do es not have

of as a dyadic op erator whose value is simply that

a unique inverse (there maybemany lo cations with

of its right-hand op erand. Comp ound expressions

the same value as that of x). If the o ccurrence of

have a similar app earance and function as a list of

x is interpreted as \compute the eld p ointed at

statements in algol. The pair of symbols b egin

by x and take its contents," one could attachto

and end or left and right parentheses maybeusedto

@x the meaning: \p erform the op eration describ ed

embrace such a comp ound expression and convert it

ab ove, but suppress the extraction of the contents."

into a simple expression. A blo ck is merely a sp ecial

But \@" could still not b e used as unary op erator,

case of this construction which happ ens to contain

since @(x + y )oreven @@x would b e meaningless,

declarations; thus the value of a blo ck is de ned to

whereas :(x + y )and::x b oth make sense.

b e the value of its constituent comp ound expression.

Second, one of the ma jor ob jectives of bliss is

The op erator \ "isadyadic op erator which

to p ermit the programmer to de ne arbitrary rep-

should b e read as \store into." More precisely,the

resentations of data structures (as will b e discussed

expression \  " means: the (uninterpreted)

1 2

later). In order to accomplish this it is necessary

bit pattern resulting from the evaluation of the

to not only allow op erations on p ointers, but also

expression  is to b e stored into the eld named by

2

to allow the value of an arbitrary expression to b e

the p ointer resulting from the evaluation of  .In

1

interpreted as a p ointer, i.e., a name. Since the

algol the statement x := x + 1 causes the value of

semantic interpretation of identi ers is indep endent

x to b e incremented by one. Coupling the de nition

of context, and consequently so is that of all expres-

of \ " given ab ove with the interpretation of

sions, it is p ossible to do this in a consistent manner.

identi ers and the dot op erator, the equivalent bliss

A consistentinterpretation is much more dicult in

would b e x :x + 1. The value of the assignment

the case of context-dep endentinterpretations (since

op erator is de ned to b e identical to that of its right-

static context is inadequate in expressions involv-

hand op erand; thus, the value of x :x +1 is 4

case e of set  ;  ; ::: ;  ;  tes the incremented value of the cell named by x.The

0 1 n1 n

select e of

comp ound expression \(y x; z ::y + 1)" causes

nset  :  ;  :  ; ::: ;  :  tesn

0 1 2 3 2n 2n+1

a p ointer to x to b e stored into y , then computes the

value of the eld named by x (accessed indirectly

The value of a case expression is  ; that is, the

e

through y ) plus one and stores this value in z ;in

expression e is evaluated, and this value is used

this case this value is also that of the comp ound

to select one of the expressions,  (0  i  n),

i

expression. The imp ortant thing to remember about

to evaluate. The value of  b ecomes the value of

i

the assignment op eration, e.g.   , isthatit

1 2

the entire case expression. The value of a case

assigns a value to the eld named by  , not  itself.

1 1

expression is unde ned if e is not in the range

There is the usual complement of arithmetic,

0  e  n. The select expression is somewhat

logical, and relational op erators. Logical op erators

similar to the case expression, with the distinction

op erate on all bits of a eld; relational op erators

that the value of e is not restricted to the range

yield a value 1 if the relation is satis ed, and 0

0  e  n. Execution of the select pro ceeds as

otherwise.

follows: (l) the value of e is computed; (2) the values

We will describ e six forms of explicit control ex-

of the expressions  (0  i  n)areevaluated; (3)

2i

pressions: conditional, lo oping, case-select, function

for each i suchthate =  , the expression  is

2 2i+1

call, call, and escap e. For this discussion it

evaluated. If there is no i suchthate =  ,the

2i

will b e convenient to use the symbols  or e, p ossibly

value of the select expression is de ned to b e 1.

subscripted, to represent arbitrary expressions.

In the event that one or more values of i exist such

The conditional expression is of the form \if 

1

that e =  ,each of these expressions is evaluated

2i

then  else  " and is de ned to evaluate, and have

2 3

in ascending order of the values of i;inthiscasethe

the value of,  just in case the rightmost bit of  is

2 1

nal value of the select expression is taken to b e

a 1 and evaluates, and has the value of,  otherwise.

3

that of the last of these expressions to b e evaluated.

The abbreviated form \if  then  " is considered

1 2

The particular choice of 1 as the value of

to b e identical to \if  then  else 0".

1 2

lo op expressions and select expressions is almost

There are six basic forms of lo oping expressions:

but not entirely arbitrary. It mighthave b een

preferable to have them return a unique \unde ned"

while  do 

1

or \nil" value, but no suchvalue was available do  while 

1

until  do 

for the particular machine for which bliss was 1

do  until 

1

implemented. The value 1was chosen principally

incr hnamei from  to  by  do 

1 2 3

b ecause it is marginally cheap er (in co de pro duced)

decr hnamei from  to  by  do 

1 2 3

to generate this value and test the sign of a value

in the pdp-10. Also, zero-relative indexing is

Each form of lo oping expression implies rep eated

common, and a negativevalue is clearly illegal in

execution (p ossibly zero times) of the expression

such contexts. Beyond these minor justi cations

denoted  until a sp eci c condition is satis ed.

the only imp ortant prop erty ofthischoice is its

In the rst form (while...do) the expression  is

uniformity.

rep eated so long as the rightmost bit of  remains

1

It should b e noted that the set of control ex-

1. The second form is similar to the rst except

pressions presented thus far is not minimal. All of

that  is evaluated b efore  ,thus guaranteeing at

1

the lo op expressions could b e constructed from the

least one execution of . The until forms are similar

\while...do" form, and case and select expressions

to the while forms except that the condition is

could b e constructed from conditional expressions,

negated. The last two forms are similar to the

for example. The decision to include a fairly rich

familiar\step...until" construct of algol, except:

collection of control structures in part resulted from

(l) the control variable is lo cal to ;(2) ,  ,

1 2

another decision, to b e discussed shortly, not to

and  are computed only once (b efore entry to the

3

include the familar go to statement form of control.

lo op); and (3) the direction of the step is explicitly

This decision suggests that the designers must pay

indicated (incrementor decrement). Except for

far more attention to the range of control forms

the p ossibility of an escap e expression within  (see

included, since there is no way for the user to synthe-

b elow), the value of a lo op expression is uniformly

size his own control from the more primitive(go to)

taken to b e 1.

control form. In the case of bliss two criteria were

We shall treat somewhat simpli ed versions of the

case and select expressions here; these forms are: 5

applied to determine whether a prop osed control The b o dy of any function may b e activated as

form should b e included: a coroutine and/or asynchronous pro cess. An ar-

bitrary numb er of distinct incarnations of a single

1. Was there a reasonable application for which b o dy are allowed; indeed, arbitrarily manyincar-

the mo de of expression without the prop osed nations of a function b o dy as b oth coroutines and

construct was awkward and/or obscure? subroutines may exist simultaneously. In order to

2. Was it p ossible to compile b etter co de utilizing permit anyofseveral useful styles of coroutine mech-

the additional information provided by the new anism, only two primitive op erations are provided

construct than would have b een p ossible other- directly in the language:

wise?

1 2 n

create  ( ,  , :: : ,  )at length  then 

2 3 4

exchj ( ,  )

5 6

All of the control expressions discussed ab ove satisfy

at least one and usually b oth of these criteria.

More complex coroutine call conventions can easily

The select expression, for example, b oth pro duces

b e constructed from these primitives. (Note that

more ecient co de and is a more natural, obvious

any of the expressions represented by 's ab ovemay

mo de of expression than the equivalent case or

evaluate at execution time.)

if formulation when the selection criteria involves

The e ect of the create expression is to establish

noncontiguous values.

a new, indep endent context (that is a stack) for

A function call expression has the form \ ( ,

1

the function named by  with actual parameter

1 n

 , ::: ,  )". This expression causes activation

2 n

values  , ::: ,  . The stackissetupbeginning

of the segment named by  as a subprogram with

at the word named by  and is of size  words

2 3

an initialization of the formal parameters named in

(to provide over ow protection). The activation

the declaration of the function to the values of the

p oint for the newly created coroutine is set to the

actual parameters  , ::: ,  . Only call-by-value (in

1 n

head of the function named by .Thevalue of the

the algol sense) parameters are allowed; however,

create expression is a \pro cess name" for the new

call-by-reference is implicitly available since names,

coroutine. Control then passes on to the expression

p ointer values, may b e passed. The value of a

following the create|in particular, the expression

function call is that resulting from execution of the

 is not executed at this time and the b o dy of  is

4

b o dy of the function. Thus, for example, the value

not activated. When two or more such contexts have

of the following blo ckis120.

b een established, control maybepassedfromthe

currently executing one to any other by executing an

b egin

\exchange jump," exchj, expression. An expression

function f actor ial (n)=

\exchj( ,  )" will cause control to pass to the

5 6

if :n  1 then 1 else :n  f actor ial (:n 1);

coroutine named by  (the value of an earlier

5

f actor ial (5)

create expression). The value  b ecomes the value

end

6

of the exchj op eration which last caused control

Note that a function call need not explicitly name

to pass out of the coroutine named by  . Thus,

5

a function by its asso ciated identi er; all that is

e ectively,  may b e passed as a parameter to the

6

required is that  evaluate to the name of a segment.

coroutine b eing reactivated.

Thus expressions such as the following are valid and

The expression  , one will note, is not executed

4

useful:

at the time at which a coroutine is created. Instead

this expression is executed only when and if control

(case :x of set P 1; P 2; P 3 tes)(.z)

passes out of the b o dy of the coroutine by a normal

Note in this example that the o ccurrence of a param- subroutine-typ e return (e.g. \falling through the end

eter list enclosed in brackets triggers a function call. of its b o dy"). The normal minimal action to b e

An identi er by itself merely denotes a p ointer to the exp ected of  is to return the stack space used by

4

named segment; thus P 1, P 2, and P 3 are the names the coroutine and to exchj to some other, active,

of functions (not the result of executing them) and coroutine. In such a case, a subroutine-typ e return

the value of the case expression is the name of one of from a coroutine corresp onds to the coroutine killing

these functions. The value of the entire expression its own existence.

ab ove is the result of executing one of the functions The coroutine mechanism describ ed ab ove is il-

P 1, P 2, or P 3 with actual parameter :z .Function lustrated by the following skeletal example. (The

calls with no parameters are written \ ()". 6

exit op erations in this example are instances of an and (2) the authors feel strongly that the general

\escap e expression" (which is explained in the sub- go to, b ecause of the implied violation of program

sequent material). In this case, if (when) executed structure, is a ma jor villain in programs whichare

they will cause control to pass to the end of the dicult to understand, mo dify, and debug. There

blo ck.) are \go o d" and \bad" ways to use a go to, and there

are restrictions which could b e imp osed which elim-

b egin

inate the need for run-time supp ort. Consideration

own pa, pb, s1[100], s2[100];

of the nature of \go o d" ways, and of the restrictions

function a =

necessary to eliminate run-time overhead, led us to

b egin lo cal la, x;

eliminate the go to altogether, and to the inclusion

.

.

.

of a rich collection of conditional, lo oping, and case-

x exchj(:pb, la);

select expressions. These alone, however, are not

.

. suciently general, or convenient, and consequently

.

the \escap e" expressions were intro duced. There are

end;

eight forms of the escap e mechanism, one for each

function b(z )=

form of control environment:

b egin lo cal lb, y ;

.

.

.

exitblo ck  exitcase 

y exchj(:z , lb);

exitcomp ound  exitselect 

.

.

exitlo op  exit 

.

end;

exitset  return 

pa create a() at s1 length 100 then exit;

Each escap e expression causes control to exit from

pb create b(:pa) at s2 length 100 then exit;

a sp eci ed control environment(ablock, a lo op, or

exchj(:pa, 0);

end

a conditional expression, for example) and de nes

avalue () for that control expression (exit exits

Execution of the main b o dy of this blo ck creates two

from any form of control expression, return exits

coroutine contexts, one for the function a and one

from a function). Essentially the escap e mechanism

for b, and stores pro cess names for these in pa and

provides a highly structured form of forward branch

pb, resp ectively. The function b has one formal

whichisawkward to obtain with the other control

parameter whose value is initialized to :pa, i.e. to

expressions.

the pro cess name of an incarnation of a. The main

Consider a linked list of twoword cells, the rst

b o dy then causes control to pass, via the exchj,to

of which contains a link (p ointer) to the next cell

the coroutine named by :pa|that is, an incarnation

(the last cell has link = 0) and the second of which

of a, in this case. The activation p ointofboth

contains data. The following expression illustrates

coroutines at this time is at the head of their b o dies.

one use of an escap e expression; the expression has a

At some p oint in the execution of a the execution of

value whichisthepointer to the rst negativedata

\x exchj(:pb, la)" will cause control to pass to

item, or a value of 1ifnosuch item is found. The

the coroutine named by :pb,leaving the activation

address of the head of the list is contained in a eld

p ointofa at the store op eration. Similarly, at some

called head.

later time the execution of \y exchj(:z , lb)" will

(register t; t head; while (t ::t) 6=0 do

cause control to return to a (since :z  :pa  a

if :(:t + l ) < 0 then exitlo op :t);

pro cess name of a) at its activation p oint and leave

the activation p ointofb at its store-op eration. The

Note that the initialization of (t head)setsthe

value of the exchj op eration in a is de ned to b e

value of t to a p ointer to head,notthecontents of

that of the parameter in the exchj op eration which

head.

caused control to return to a; hence in this case a

It is interesting to note that the decision to

p ointer to the lo cal variable lb will b e stored in x.

remove the go to from bliss and the decision

The familiar \go to...l abel "formofcontrol has

to make bliss an expression language are closely

not b een included in bliss. There are two reasons

related. The presence of the go to presents some

for this: (1) unrestricted go to's require consider-

awkward situations in the implementation of an

able run-time supp ort (principally due to the p os-

expression language|for example,

sibility of jumping out of functions and/or blo cks), 7

go to L; ::: ; x a + b  (L : C d); ::: is p ossible to write large systems that may b e easily

mo di ed, it is imp erative that the sp eci cations of

or

the representation of a data structure b e separated

from the sp eci cation of algorithms which manipu-

x a(if b then c else go to L); :::

late data in that structure. This principle is severely

With the go to eliminated from the language

violated in assembly languages where, typically,the

it b ecomes desirable to implement an expression

co de to access an element of a structure, for exam-

rather than a statement oriented language. Part

ple, simply a contiguous eld of bits within a word,

of the burden carried bythe go to in conventional

is co ded \in line" at the p oint where the elementis

languages shifts to numeric values whichcontrol

needed. A comparatively trivial change which alters

conditional, lo op, case, or select expressions.

the size or p osition of the eld may require lo cating

and mo difying all references to the eld. This simple

3. Data Structures

problem could b e solved by following go o d co ding

One of the outstanding characteristics of systems

practice and, p erhaps, by the use of macros; not all

programs is their concern with the wide varietyof

changes are of such a trivial nature, however.

data structures and schemes for representing these

The concept of a \p ointer" to a eld (of bits

structures. Observation of what systems program-

within a word) was mentioned earlier. Actually,

mers do reveals that a large fraction of their design

in bliss a p ointer is a 5-tuple consisting of: (l) a

e ort is sp ent in constructing representations for

word address, (2) a eld p osition, (3) a eld size,

eciently enco ding the information to b e pro cessed.

(4) an (index) register name, and (5) an \indirect

It is frequently the case that the most dicult task

address" bit. These vequantities are enco ded

in making a mo di cation to an existing program

inasingleword and as such are a manipulatable

is that of representing the additional information

item in the language (a prerequisite of algorithmic

required (e.g. the infamous \ nd another bit" prob-

representational sp eci cation). For simplicity,we

lem). Consequently the issue of representation was

discuss only the rst three of these quantities; the

one of the central design considerations in bliss.

reader is referred to the bliss reference manual [6]

Two principles were followed in the design of the

for more detail. The word address, wa, eld of a

data structure facilityof bliss:

p ointer designates the physical machine address of

the word; the p osition, p, and size, s, designate a

 the user must b e able to sp ecify the accessing

eld within a word in terms of the numberofbitsto

algorithm for elements of a structure,

the right of and within the eld. The notation used

 the structure de nition and the algorithms which

in bliss to sp ecify a p ointer (taking only the simple

op erate on the elements of a structure must

wa, p, s case) is \wahp; si".

b e separated in suchaway that either can b e

Assume that the declaration \own x[100]" has

mo di ed without a ecting the other.

b een made. The identi er x is b ound by this

particular declaration to a p ointer to the 36-bit eld

The rst principle is in accordance with the exibil-

which is the rst word of this 100-word segment.

ity and eciency the bliss programmer should b e

That is, the word address of the p ointer x is that

provided with in utilizing the machine features. It

of the lo cation allo cated to the segment, and the

expresses our strong feelings that we cannot|and

p osition and size elds havevalues of 0 and 36,

should not try to|predict which kind of structures

resp ectively.Ifwe denote the address of the segment

a system programmer will need, so that a given set

by , then an o ccurrence of x in a bliss program

x

of primitive structures and other statically de ned

is identical to an o ccurrence of \ h0; 36i". If  ,

x 0

structures is inadequate. The feature of a structure

 ,and are expressions, then the syntactic form

1 2

declaration, on the other hand, in which the user

\ ( ,  )" is by de nition a p ointer whose word

0 1 2

18

himself sp eci es the way in which elements are

address is the value of  (mo dulo 2 ) and whose

0

accessed, provides the user with the full exibility

p osition and size sp eci cations are the values of 

1

6

and eciency he needs. This p oint is illustrated

and  (mo dulo 2 ) resp ectively.Thus \X h3; 4i"is

2

b elowby taking as an example the well-known ar-

a p ointer to a four-bit eld three bits from the right

ray structure. The di erence with the static array

end of a word named X . The word address, p osition,

structure of algol is demonstrated by discussing

and size information are enco ded within a p ointer in

several varieties of accessing an array.

suchaway that adding small integers to a p ointer

In order to achieve a language in terms of whichit

increments the word address. Thus \X +1"isa 8

p ointer to the word following X (unless the address function ar y 2(f 0, f 1, f 2) = (:f 0+ :f 1  10 + :f 2);

eld over ows).

The expressions x[:a; :b] and y [:b; :a] corresp ond to

In order to satisfy the ob jectives set out ab ove

calls on this function, i.e. to ar y 2(x, :a, :b) and

for data structures, it is desirable to extend the

ar y 2(y , :b, :a).

allo cation declarations (global, own, lo cal, etc.)

A function declaration such as that shown ab ove

describ ed ab ove. However, for exp osition weshall

implicitly declares identi ers and allo cates storage

rst describ e the structure mechanism in terms of

for its formal parameters. These are functionally

the allo cation declarations already available, then

equivalent to those declared lo cal (in scop e and

describ e the extensions when more motivation is

extent), and are initialized to the p ositionally equiv-

p ossible.

alent actual parameter when the function is invoked.

The de nition of a class of structures, that is,

Consistent with the interpretation of identi ers, the

of an accessing algorithm to b e asso ciated with

value of a formal parameter identi er, say f 0, is a

certain sp eci c data structures, maybemadebya

p ointer to the lo cation allo cated for the formal (on

declaration of the form:

this, p ossibly recursive, invo cation), and :f 0 denotes

structure hnamei[hformal parameter listi] = 

its value.

Since, in a structure declaration, there is an

Particular names may then b e asso ciated with a

implicit, unnamed formal parameter, the name of

structure class, that is with an accessing algorithm,

the structure class itself is used to denote this

by another declaration

\zero-th" parameter. This convention maintains the

p ositional corresp ondence of actuals and formals.

map hnameihname listi,

Thus, in the example ab ove, :ar y 2 denotes the value

where a hname listi is a sequence of names separated

of the zero-th parameter, that is the name of the

by colons.

particular segment b eing referenced, and x[:a, :b]is

Consider the following example:

equivalentto(x + :a  10 + :b). The value of this

expression is a p ointer to the designated elementof

b egin

the segment named by x.

structure ar y 2[i; j ]= (:ar y 2+:i  10  :j );

In the following example the structure facility and

own x[100], y [100], z [100];

bind declaration have b een used to eciently enco de

map ar y 2 x:y :z ;

P

9

a matrix pro duct (z = x y ). In the inner

.

i;j ik kj

k =0

.

.

blo ck the names xr and yc are b ound to p ointers

x[:a; :b] :y [:b; :a];

to the base of a sp eci ed rowofx and column of

.

.

y resp ectively. These identi ers are then asso ciated

.

with structure classes which allow one-dimensional

end;

access.

In this example weintro duce a very simple struc-

b egin

ture, ar y 2, for two-dimensional (10  10) arrays,

structure ar y 2[i; j ]= (:ar y 2+:i  10 + :j );

declare three segments with names x, y ,andz

row[i]= (:r ow + :i);

b ound to them, and asso ciate the structure class

col [j ]=(:col + :j  10);

ar y 2 with these names. The syntactic forms x[ ; ]

1 2

own x[100], y [100], z [100];

and y [ ; ] are valid within this blo ck and denote

3 4

map ar y 2 x:y :z ;

evaluation of the accessing algorithm de ned bythe

.

.

.

ar y 2-structure declaration (with an appropriate

incr i from 0 to 9 do

substitution of actual for formal parameters).

b egin bind xr = x[:i; 0], zr = z [:1; 0];

Although they are not implemented in this way,

map row xr:zr;

for purp oses of exp osition one may think of the

incr j from 0 to 9 do

structure declaration as de ning a function with one

begin

more formal parameter than is explicitly mentioned.

register t; bind yc = y [0;:j];mapcol y c;

For example, the structure declaration in the previ-

t 0;

ous example,

incr k from 0 to 9 do

t :t + :xr [:k ]  :y c[:k ];

structure ar y 2[i, j ]= (:ar y 2+:i  10 + :j );

zr[:j ] :t;

end;

conceptually is identical to a function declaration 9

end; a user de ned dynamic allo cation function. Any

.

of the expressions  ,  ,or (but esp ecially 

1 2 3 1

.

.

and  )mayinvolve undotted formals and thus b e

3

end

instance sp eci c. Consider the following example,

which also illustrates the extension to the allo cation

Supp ose now that one wishes to alter the representa-

declarations:

tion of the structure ar y 2, and access to the arrayis

to b e made through a dop e vector to de ne the rela-

b egin

tive base of eachrow. The ma jor change required is

structure ar y 2[i; j ]=[i  j ](:ar y 2+:i  j + :j );

to replace the current structure declaration for ar y 2

own ar y 2 x:y :z [10; 10];

by

.

.

.

own i1[10];maprow i1;

end;

structure ar y 2[i; j ]= (:ar y 2+:i1[;i]+ :j );

This is essentially the same example as has already

With this representation, the use of a sp ecial ac-

b een presented of three, two-dimensional, 10  10 ar-

cessing algorithm (structure) for accessing columns

rays. However, the information previously contained

b ecomes

in a map declaration has now b een included in the

allo cation declaration. More imp ortantly, note that

structure col [j ]= (:col + :i1[:j ]);

undotted formal names, which corresp ond to the

As can b e seen, these fairly simple changes in the

\instance actuals: 10,10" are used to compute the

program completely change its representation of the

size of the instances|as well as in the accessing

data. No changes in the pro cessing algorithm are

algorithm itself. (As in algol declarations, the

required.

instance-actuals distribute over the names to their

left.) Thus the single structure declaration, ar y 2,

4. More on Data Structures

may b e used for other instances of similarly struc-

The example ab ove has the disadvantage of using

tured segments which happ en to b e of a size other

the size of the array explicitly in the access algo-

than 10  10.

rithm, so that separate structure declarations would

The form of allo cation and structure declarations

b e required for arrays of di erentsize. It should

illustrated previously are instances of the extended

b e p ossible for obvious reasons to parameterize the

syntax in whichtheobvious defaults are chosen.

dep endency of the size of the information onto which

Dynamic allo cation, of an admittedly simple

the structure is going to b e mapp ed. The required

kind, is illustrated by the following example:

exibilityisachieved by observing that until now

b egin

it only makes sense to use \dotted formals" in the

own space[10000];own spaceptr ; external er r or ;

access algorithm, b ecause bliss has a strict value

function l ocspacemg r (tog ; numb; base)=

substitution of parameters. Thus, if we wish (and we

if :tog

do so wish), another interpretation can b e placed on

then

the o ccurrence of \undotted formals" in the access

b egin

algorithm. In particular, we shall use the undotted

if (spaceptr :spaceptr + :numb) > 10000 then

formal parameter names to denote the value of

return er r or ();

space + :spaceptr :numb;

parameters asso ciated with particular instances of

end

a structure (as distinct from instances of accesses to

else (if (space + :spaceptr ) >:base then

that structure).

spaceptr :base space);

Using \f"and\g"toembrace optional syntax

structure lary[i; j ]=

(i.e. \zero or one instance of"), the bliss structure

[i  j; l ocspacemg r ](:l ar y + :i  j + :j );

declaration is of the form

lo cal lary x[:n; :m +1], y [3; 5];

.

structure hnamei[hformal parameter listi]

.

.

= f[ f; g]g

1 2 3

end

where  is the accessing algorithm as b efore, 

3 1

The lo cal allo cation declaration in this example,

is an expression whose value determines the size

lo cal lary x : : :, contains expressions whichmust

(in words) of an instance of this structure, and

be evaluated at run-time as instance-actuals; hence

 is an expression whose value is the name of

2

dynamic allo cation is required. Note that the 10

own application. Indeed, one might exp ect di erent structure declaration for lary contains the name of

allo cation p olicies to b e asso ciated with di erent the function l ocspacemg r in the p osition denoted

structures, or even di erent instances of the same  in the extended structure declaration syntax.

2

structure, in a single program. In fact the value of  is required to b e that of

2

a function with three formal parameters, say pl ,

Conclusions p2, and p3. This function is automatically called

(p ossibly several times) at entry and exit from a

Wehave attempted to presentabove the main fea- blo ck containing an allo cation declaration which

tures of bliss, a language we feel esp ecially suited sp eci es a structure declaration whichmentions it.

to that application area usually called \systems The interpretation of the parameters is:

programming."At least one p ossible interpretation p1= 1 The function is to allo cate a segmentof

of this description is as an indirect de nition of size p2(words), and return a p ointer to this segment.

the system programming \problem area." In the p2 will b e the value of the size expression in the

simplest case, this manifests itself in our break with structure declaration. p3 has no meaning.

the traditional interpretation of identi ers in higher- p1= 0 The function is to deallo cate a segment

level languages as the consequent demand on the of p2words whose b eginning is p ointed to by p3(p3

programmer to b e consciously aware of the distinc- is the value returned by a previous call with p1= 1).

tion b etween name and value. Similarly, the struc- The value of the function in this case is immaterial.

ture mechanism maybeinterpreted as a statement Thus, in the example instances of structures of

of our judgement as to the extreme imp ortance of typ e lary are allo cated from the segmentnamed

the representation, mo di cation, allo cation issues in space. Examination of the function l ocspacemg r

systems programming|and hence that these issues reveals that it allo cates on a last-in- rst-out basis,

must b e explicitly at the programmer's attention and hence this particular allo cation function is only

and control. The decision to exclude the go to state- suitable for lo cal (stack discipline) variables. It

ment is similarly a consequence of our judgement should also b e noted that the example ab oveis

as to the imp ortance of writing highly structured similar to the following blo ck, which uses only the

programs so that they may b e read, understo o d, and simpler declarations of the previous section. (Note

mo di ed. that the example is not completely equivalentdue

Considerable exp erience has b een gained in the to p ossible identi er con icts.)

use of bliss for writing systems. The bliss compiler

b egin

itself, an apl system, a watfor-likefast fortran

own space[10000];own spaceptr ;

compiler, simula-likeevent based simulation sys-

function l ocspacemg r (tog ; numb; base)=

tem, chess playing programs, input-output routines,

% same as ab ove %

debugging aids, parts of an op erating system, and

bind i1=:n; j 1=:m +1;

so on, have b een written in bliss. This represents

structure lary1[i; j ]=(:l ar y 1+:i  j 1+:j );

on the order of 100,000 lines of co de, and forms a

bind i2=3, j 2= 5;

reasonable base for forming some conclusions ab out structure lary2[i; j ]=(:l ar y 2+:i  j 2+:j );

bind x = l ocspacemg r (1;i1  j 1; 0); map lary1 x;

the language. By such measures as readability and

bind y = l ocspacemg r (1;i2  j 2; 0);maplary2 y ;

mo di ability, lines of (debugged) co de pro duced p er

.

programmer p er day, quality of co de pro duced by

.

.

the compiler, and user reaction, the language has

l ocspacemg r (0;i1  j 1;x);

b een a success.

l ocspacemg r (0;i2  j 2;y);

Of more interest, p erhaps, are the things which

end

wehave learned which will cause us to extend the

This example illustrates that the extended decla-

language or do things di erentlyifwewere to do

rations intro duce no additional p ower; however, the

them over again. Wemention three, one of whichis

extensions do p ermit considerable simpli cation and

currently b eing implemented.

clarity.

1. The implementation presumes a stackwhich

The requirement that the programmer provide

is used for parameters to functions, return links,

his own dynamic allo cation function was intro duced

and lo cal variables. The user do es not have direct

principally to avoid prerequisite run-time supp ort.

control over the implicit structure. Since the im-

However, the e ect is that the user may de ne

plementation is quite ecient, there is little reason

allo cation p olicies particularly appropriate to his

for the user to override it so long as his entire 11

the bliss compiler will, under control of a compile system is written in bliss.However, if one wishes

time toggle, cause a user-de ned function to b e to use bliss to rewrite parts of an existing system

called on eachentry (and exit) from a control (for example, we are rewriting parts of the pdp-

environment (blo ck, conditional, lo op, function, 10 op erating system), one nds that con icts in

etc.). Parameters to this function sp ecify the parameter passing conventions, register conventions,

(source) line numb er, typ e of control environment, etc., arise.

etc. The user may, of course, do whatever he pleases A partial solution to these problems is imple-

in this function; however, standard functions have mented in the current compiler in that the user

b een written whichcount the frequency of execution may control the compiler's register allo cation p ol-

of the various expressions and accumulate the time icy. Another partial solution (not yet implemented)

sp ent in these expressions. Very simple analysis of would p ermit a structure to b e asso ciated with a

the data collected by these routines can so helpful function to sp ecify how parameters are accessed.

in determining when further e ort will b e fruitful. The most dicult asp ect of the problem is to devise

a means by which the user may sp ecify the schema

for generation of prologue and epilogue co de.

2. The \escap e" mechanism is essential in the

Acknow ledgments. Wewould like to express our

context of a \go to-less" language. It is unfortunate

deep gratitude to Messrs. Geschke, Wile, and Ap-

that wehave eight separate op erations (exitlo op,

p erson (graduate students at Carnegie-Mellon Uni-

exitblo ck, etc.), all of which p erform essentially

versity), eachofwhomhasmadevaluable contribu-

the same function. Our mistakewas in assuming

tions to b oth the design and implementation of the

that there is no need for a lab el once the go to

language.

is removed. It would have b een b etter to p ermit

a control environment (a blo ck, a lo op, or what-

References

ever) to b e lab eled, and to use a single op eration,

say\leave hlab eli ", to cover all of these cases.

1. epl reference manual, Pro ject mac, April 1966.

A simple extension to this notion, \leave hfunction

2. Burroughs B5500 Extended algol reference

namei ", could cause an exit from several (nested)

manual. Burroughs Corp., Detroit, Mich.

calls.

3. Wirth, N. \PL/360, A

3. An assumption made by advo cates of imple-

for the 360 ." J. ACM 15, 1 (Jan.

mentation languages, including the authors, is that

1968), 37{74.

systems written in a higher-level language will b e

4. Richards, M. \bcpl: A to ol for compiler writing

ultimately more ecient than those pro duced in

and system programming."Proc. afips 1969

assembly language. The reasoning b ehind this as-

sjcc,Vol. 34, afips Press, Montvale, N.J.,

sumption is simply that the cost of redesigning and

pp. 557{566.

reco ding \critical" p ortions of a system is smaller

5. Naur, P., and Randell, B. (Eds.) \Software

when it is written in a higher-level language than

engineering." Scienti c A airs Div., nato,

when it is written in assembly co de, and hence it is

Brussels, Belgium (Conference held in Jan. 1969

more practical to p olish the nal pro duct. The cor-

in Garmish).

rectness of this assumption dep ends up on knowing

6. bliss reference manual. Computer Science

which p ortions of the system are the \critical" ones.

Dept. Rep., Carnegie-Mellon University, Pitts-

Exp erience indicates that our intuition ab out such

burgh, Pa., Jan. 15, 197O.

things is p o or.

7. pdp-10 reference handb o ok. Digital Equipment

It might b e argued that should

Corp oration, Maynard, MA, 197O.

build mechanisms into their system to measure its

8. Lang, Charles A. \SAL|Systems Assembly

eciency|indeed the same argumentmaybemade

Language." Pro c. afips 1969 sjcc,Vol. 34,

for built-in debugging to ols. In practice, however,

afips Press, Montvale, N.J., pp. 543{555.

given the decision of how to exp end to day's e ort,

9. Bell, J. \The quadratic quotient metho d: A hash

a programmer will usually opt for pushing the main

co de eliminating secondary clustering." Comm.

line of the pro ject rather than building these supp ort

ACM 13,2(Feb. 1970), pp. 107{109.

to ols. On the other hand, he will use suchtools

if they already exist. One such to ol installed in 12