Programming Language Design Concepts 1st Edition Findlay instant download
Programming Language Design Concepts 1st Edition Findlay instant download
https://ebookname.com/product/programming-language-design-
concepts-1st-edition-findlay/
https://ebookname.com/product/java-programming-exercises-volume-
one-language-fundamentals-and-core-concepts-1st-edition-
christian-ullenboom/
https://ebookname.com/product/programming-language-
foundations-1st-edition-aaron-stump/
https://ebookname.com/product/mips-assembly-language-programming-
robert-britton/
https://ebookname.com/product/renin-angiotensin-system-and-
cardiovascular-disease-1st-edition-walmor-c-demello-md/
Computer Viruses For Dummies Peter H. Gregory
https://ebookname.com/product/computer-viruses-for-dummies-peter-
h-gregory/
https://ebookname.com/product/agrip-af-noregskonungas%c7%abgum-a-
twelfth-century-synoptic-history-of-the-kings-of-norway-2nd-
revised-edition-matthew-james-driscoll/
https://ebookname.com/product/buddhist-public-advocacy-and-
activism-in-thailand-a-rhetoric-of-dignity-and-duty-2024th-
edition-craig-m-pinkerton/
https://ebookname.com/product/critical-companion-to-t-s-eliot-a-
literary-reference-to-his-life-and-work-1st-edition-russell-
elliott-murphy/
Atoms and materials 1st Edition Kyle
https://ebookname.com/product/atoms-and-materials-1st-edition-
kyle/
PROGRAMMING LANGUAGE
DESIGN CONCEPTS
PROGRAMMING LANGUAGE
DESIGN CONCEPTS
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, scanning or otherwise, except under
the terms of the Copyright, Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright
Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP, UK, without the permission in writing of the
Publisher, with the exception of any material supplied specifically for the purpose of being entered and executed
on a computer system for exclusive use by the purchase of the publication. Requests to the Publisher should be
addressed to the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West
Sussex PO19 8SQ, England, or emailed to permreq@wiley.co.uk, or faxed to (+44) 1243 770620.
This publication is designed to provide accurate and authoritative information in regard to the subject matter
covered. It is sold on the understanding that the Publisher is not engaged in rendering professional services. If
professional advice or other expert assistance is required, the services of a competent professional should be sought.
John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA
John Wiley & Sons Australia Ltd, 33 Park Road, Milton, Queensland 4064, Australia
John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809
John Wiley & Sons Canada Ltd, 22 Worcester Road, Etobicoke, Ontario, Canada M9W 1L1
Wiley also publishes its books in a variety of electronic formats. Some content that appears
in print may not be available in electronic books.
A catalogue record for this book is available from the British Library
ISBN 0-470-85320-4
Preface xv
Part I: Introduction 1
1 Programming languages 3
1.1 Programming linguistics 3
1.1.1 Concepts and paradigms 3
1.1.2 Syntax, semantics, and pragmatics 5
1.1.3 Language processors 6
1.2 Historical development 6
Summary 10
Further reading 10
Exercises 10
vii
viii Contents
10 Concurrency 231
10.1 Why concurrency? 231
10.2 Programs and processes 233
10.3 Problems with concurrency 234
10.3.1 Nondeterminism 234
10.3.2 Speed dependence 234
10.3.3 Deadlock 236
10.3.4 Starvation 237
10.4 Process interactions 238
10.4.1 Independent processes 238
10.4.2 Competing processes 238
10.4.3 Communicating processes 239
10.5 Concurrency primitives 240
10.5.1 Process creation and control 241
10.5.2 Interrupts 243
10.5.3 Spin locks and wait-free algorithms 243
10.5.4 Events 248
10.5.5 Semaphores 249
10.5.6 Messages 251
10.5.7 Remote procedure calls 252
10.6 Concurrent control abstractions 253
10.6.1 Conditional critical regions 253
10.6.2 Monitors 255
10.6.3 Rendezvous 256
Summary 258
Further reading 258
Exercises 259
Summary 328
Further reading 328
Exercises 329
The first programming language I ever learned was ALGOL60. This language was
notable for its elegance and its regularity; for all its imperfections, it stood head and
shoulders above its contemporaries. My interest in languages was awakened, and
I began to perceive the benefits of simplicity and consistency in language design.
Since then I have learned and programmed in about a dozen other languages,
and I have struck a nodding acquaintance with many more. Like many pro-
grammers, I have found that certain languages make programming distasteful, a
drudgery; others make programming enjoyable, even esthetically pleasing. A good
language, like a good mathematical notation, helps us to formulate and communi-
cate ideas clearly. My personal favorites have been PASCAL, ADA, ML, and JAVA.
Each of these languages has sharpened my understanding of what programming
is (or should be) all about. PASCAL taught me structured programming and data
types. ADA taught me data abstraction, exception handling, and large-scale pro-
gramming. ML taught me functional programming and parametric polymorphism.
JAVA taught me object-oriented programming and inclusion polymorphism. I had
previously met all of these concepts, and understood them in principle, but I did
not truly understand them until I had the opportunity to program in languages
that exposed them clearly.
Contents
This book consists of five parts.
Chapter 1 introduces the book with an overview of programming linguistics
(the study of programming languages) and a brief history of programming and
scripting languages.
Chapters 2–5 explain the basic concepts that underlie almost all programming
languages: values and types, variables and storage, bindings and scope, procedures
and parameters. The emphasis in these chapters is on identifying the basic
concepts and studying them individually. These basic concepts are found in almost
all languages.
Chapters 6–10 continue this theme by examining some more advanced con-
cepts: data abstraction (packages, abstract types, and classes), generic abstraction
(or templates), type systems (inclusion polymorphism, parametric polymor-
phism, overloading, and type conversions), sequencers (including exceptions), and
concurrency (primitives, conditional critical regions, monitors, and rendezvous).
These more advanced concepts are found in the more modern languages.
Chapters 11–16 survey the most important programming paradigms, compar-
ing and contrasting the long-established paradigm of imperative programming
with the increasingly important paradigms of object-oriented and concurrent pro-
gramming, the more specialized paradigms of functional and logic programming,
and the paradigm of scripting. These different paradigms are based on different
xv
xvi Preface
selections of key concepts, and give rise to sharply contrasting styles of language
and of programming. Each chapter identifies the key concepts of the subject
paradigm, and presents an overview of one or more major languages, showing
how concepts were selected and combined when the language was designed.
Several designs and implementations of a simple spellchecker are presented to
illustrate the pragmatics of programming in all of the major languages.
Chapters 17 and 18 conclude the book by looking at two issues: how to select
a suitable language for a software development project, and how to design a
new language.
The book need not be read sequentially. Chapters 1–5 should certainly be
read first, but the remaining chapters could be read in many different orders.
Chapters 11–15 are largely self-contained; my recommendation is to read at least
some of them after Chapters 1–5, in order to gain some insight into how major
languages have been designed. Figure P.1 summarizes the dependencies between
the chapters.
1
Introduction
2 3 4 5
Values and Variables and Bindings and Procedural
Types Storage Scope Abstraction
6 7 8 9 10
Data Generic Type Control Concurrency
Abstraction Abstraction Systems Flow
11 12 13 14 15 16
Imperative OO Concurrent Functional Logic Scripting
Programming Programming Programming Programming Programming
17 18
Language Language
Selection Design
Exercises
Each chapter is followed by a number of relevant exercises. These vary from
short exercises, through longer ones (marked *), up to truly demanding ones
(marked **) that could be treated as projects.
A typical exercise is to analyze some aspect of a favorite language, in the
same way that various languages are analyzed in the text. Exercises like this are
designed to deepen readers’ understanding of languages that they already know,
and to reinforce understanding of particular concepts by studying how they are
supported by different languages.
A typical project is to design some extension or modification to an existing
language. I should emphasize that language design should not be undertaken
lightly! These projects are aimed particularly at the most ambitious readers, but
all readers would benefit by at least thinking about the issues raised.
Readership
All programmers, not just language specialists, need a thorough understanding
of language concepts. This is because programming languages are our most
fundamental tools. They influence the very way we think about software design
and implementation, about algorithms and data structures.
This book is aimed at junior, senior, and graduate students of computer
science and information technology, all of whom need some understanding of
the fundamentals of programming languages. The book should also be of inter-
est to professional software engineers, especially project leaders responsible
for language evaluation and selection, designers and implementers of language
processors, and designers of new languages and of extensions to existing languages.
To derive maximum benefit from this book, the reader should be able to
program in at least two contrasting high-level languages. Language concepts can
best be understood by comparing how they are supported by different languages. A
reader who knows only a language like C, C++, or JAVA should learn a contrasting
language such as ADA (or vice versa) at the same time as studying this book.
The reader will also need to be comfortable with some elementary concepts
from discrete mathematics – sets, functions, relations, and predicate logic – as
these are used to explain a variety of language concepts. The relevant mathematical
concepts are briefly reviewed in Chapters 2 and 15, in order to keep this book
reasonably self-contained.
This book attempts to cover all the most important aspects of a large subject.
Where necessary, depth has been sacrificed for breadth. Thus the really serious
xviii Preface
student will need to follow up with more advanced studies. The book has an
extensive bibliography, and each chapter closes with suggestions for further
reading on the topics covered by the chapter.
Acknowledgments
Bob Tennent’s classic book Programming Language Principles has profoundly
influenced the way I have organized this book. Many books on programming
languages have tended to be syntax-oriented, examining several popular languages
feature by feature, without offering much insight into the underlying concepts
or how future languages might be designed. Some books are implementation-
oriented, attempting to explain concepts by showing how they are implemented
on computers. By contrast, Tennent’s book is semantics-oriented, first identifying
and explaining powerful and general semantic concepts, and only then analyzing
particular languages in terms of these concepts. In this book I have adopted Ten-
nent’s semantics-oriented approach, but placing far more emphasis on concepts
that have become more prominent in the intervening two decades.
I have also been strongly influenced, in many different ways, by the work
of Malcolm Atkinson, Peter Buneman, Luca Cardelli, Frank DeRemer, Edsger
Dijkstra, Tony Hoare, Jean Ichbiah, John Hughes, Mehdi Jazayeri, Bill Joy, Robin
Milner, Peter Mosses, Simon Peyton Jones, Phil Wadler, and Niklaus Wirth.
I wish to thank Bill Findlay for the two chapters (Chapters 10 and 13) he has
contributed to this book. His expertise on concurrent programming has made this
book broader in scope than I could have made it myself. His numerous suggestions
for my own chapters have been challenging and insightful.
Last but not least, I would like to thank the Wiley reviewers for their
constructive criticisms, and to acknowledge the assistance of the Wiley editorial
staff led by Gaynor Redvers-Mutton.
David A. Watt
Brisbane
March 2004
PART I
INTRODUCTION
1
Chapter 1
Programming languages
3
4 Chapter 1 Programming languages
Just as important as the individual concepts are the ways in which they may
be put together to design complete programming languages. Different selections
of key concepts support radically different styles of programming, which are
called paradigms. There are six major paradigms. Imperative programming is
characterized by the use of variables, commands, and procedures; object-oriented
programming by the use of objects, classes, and inheritance; concurrent pro-
gramming by the use of concurrent processes, and various control abstractions;
functional programming by the use of functions; logic programming by the use of
relations; and scripting languages by the presence of very high-level features. We
shall study all of these paradigms in Part IV of this book.
"Unless he is dead."
Larcher grasped the hand held out to him, and gratefully accepted
the aid thus offered. From that moment the two dedicated
themselves to hunt down the criminal at whose hands George
Larcher had met his death. It was as strange a compact as had ever
been made. Halting Nemesis, who had rested all these years, once
more resumed her stealthy progress, and before her ran these two
young men, as ministers of her long-delayed revenge. This junction
of unforeseen circumstances savored of the dramatic.
"The first thing to be done," said Tait, when the compact was
thus concluded, "is to read both cases."
"Both cases!" repeated Claude curiously.
"And afterward?"
"Eh! Who can say?" replied Tait, shrugging his shoulders. Several
sojourns in Paris had left their trace in Gallic gestures, and possibly
in Gallic flippancy. "We must know what foundation we have before
we build."
"Quite so! The enterprising lady who started the whole thing. Was
she also an eye-witness?"
"I can't say. Her name does not appear in the newspapers."
"Humph!" muttered Tait, scratching his chin. "Nor in those three
volumes can I find a character likely to develop into Mrs. Bezel of
Hampstead."
"I wonder who she can be," said Claude curiously, "or what she
can have to do with the case."
"That we must find out. Depend upon it, there is more in this
case than in newspapers or novel. We must find out all about Mrs.
Bezel, and," said Tait, with emphasis, "we must learn all that is to be
learned concerning John Parver."
"Who was the Man in the Iron Mask?" replied Tait, in a bantering
tone. "I cannot say. But whomsoever he may be, he knows all about
this case."
"I thought so myself. Mrs. Bezel may think that John Parver is a
nom de plume assumed by Claude Larcher."
There was a few minutes' silence, during which each man was
intent on his own thoughts. Tait, whose brain turned quicker than
that of Larcher, was the first to break the silence.
"Well," said he, moving briskly toward his bedroom door, "before
we can say or do anything we must learn the facts of the case."
As he vanished into his room Claude laid his hand on the first of
the three volumes.
CHAPTER VII.
"LET SLEEPING DOGS LIE."
Grimly satisfied that she had brought home his fault, and had
shown him his moral weakness, Fate made the next move, and sent
Larcher and his friend to Lincoln's Inn Fields to again set Hilliston on
his former journey. The paralysis of will which had seized the elder
man did not extend to the younger; for Claude arrived full of anxiety
to begin the search for the undiscovered criminal. The first result of
his compact with Tait was this visit to the lawyer.
"Surely you did not expect to see me?" said Tait, in a silky tone,
as he placed his hat on the table.
"Well, sir," said Claude, when they were all seated, and the hush
of expectancy was in the air, "I have read those papers."
"You are quite right, Claude. It is a very black case indeed. I did
all in my power to bring the criminal to justice, but without success."
"I can only conclude one thing," replied Hilliston, with great
deliberation, "that your father, suspicious of Jeringham, returned on
that night from London, and saw the parting. The result is not
difficult to foresee. It is my own opinion that there were words
between the men, possibly a struggle, and that the matter ended in
the murder of your father by Jeringham. Hence the discovery of the
body thrown into the river, hence the flight of the murderer."
"Yes. I can safely say that it was believed Jeringham was guilty,
and had fled to escape the consequences of his crime."
"In that case, how was it that Mrs. Larcher was arrested?" asked
Tait skeptically.
"You cannot have read the case carefully, to ask me that," replied
Hilliston sharply. "She was arrested on the evidence of the dagger.
Without doubt the crime was committed with the dagger, and as she
had worn it, the inference was drawn that she was the guilty person.
But she was acquitted, and left the court—as the saying is—without
a stain on her character."
"Shame killed her," said the lawyer sadly. "She was a foolish
woman in many ways,—your pardon, Claude, for so speaking,—but
she was not the woman to commit so foul a crime. Indeed, I believe
she was fondly attached to her husband till Jeringham came
between them."
"With Mrs. Bezel we will deal hereafter," he said shortly; "but who
is this John Parver!"
"A novel?"
"I trust the author has been flattering to me. By the way, who
does he say committed the crime?"
"Michael Dene."
"I and Tait. We intend to follow out this case to the end."
"Leave that to us, sir. Tait and I will attend to the active part of
the business. All we ask you to do is to give us such information as
lies in your power."
"I will do that with pleasure," said Hilliston, who by this time was
thoroughly master of himself. "What is it you wish to know."
"We wish to know all about Mrs. Bezel. Who is she? What has she
to do with the case? Why is not her name mentioned in these
pages?"
"For answers to these questions you had better apply to the lady
herself. You have her address. Why not call on her?"
The old man rose from his seat, and took a turn up and down the
room. Then he paused beside Claude, and laid a trembling hand on
the young man's shoulder.
"What do you mean by that, Mr. Hilliston?" asked the other, with a
subtle change in his tone.
"Not if I can help it. I am sorry to disoblige you, sir, but my mind
is made up. I am determined to find out the truth."
"If you are wise you will not call on Mrs. Bezel."
"All my pain is past," replied Claude quickly. "I can suffer no more
than I did when reading these papers. I must call on Mrs. Bezel; I
must know the truth, and," added he significantly, "I have your
promise to assist me."
The result of this well-meant advice was that Claude called the
next morning on Mrs. Bezel.
CHAPTER VIII.
BOTH SIDES OF THE QUESTION.
A man who leads a double life need never feel dull. He may be
nervous, anxious, fearful lest his secret should be discovered, but
the constant vigilance required to hide it preserves him from the
curse of ennui. He ever keeps the best side of his nature uppermost;
his smiles are for the world, his brow is smoothed to lull suspicion.
But to continue the simile of the ocean: in the depths lie many
terrible things which never come to the surface; things which he
scarcely dare admit even to himself. Francis Hilliston was one of
these men.
It was not Claude that he feared, for the young man was not of a
suspicious nature; and even had he been so, would certainly have
scoffed at the idea of attributing any evil to the one who had been
to him a father. Tait, silent, observant, and cynical, was the person
to be dreaded. Accustomed by his profession to read faces, Hilliston
had seen that the quiet little man was possessed of one of those
inquisitive penetrative natures, which suspect all men, and from a
look, a gesture, a pause, can draw evidence to support any suspicion
they may entertain.
"I don't mind Claude," he said, pacing up and down the room, "he
has not sufficient brain power to find out anything. I do not want
him to know. But this Tait is dangerous. He is one of those dogged
creatures, who puts his nose to the scent, and never leaves the trail
till the prey is captured. It is with him I have to deal, not with
Claude."
By this time he had put on his gloves, and stretched his hand
toward his hat, which stood on a side table. A glance in the glass
showed him how old and gray he looked, and the sight was so
unexpected that he started in dismay.
Calm, dignified, easy, he left his office, and stepped into the
brougham waiting at the door. To judge by appearance, one would
have thought him the most respectable and upright man in London.
No one knew what lurked behind that benevolent expression. His
mask had fallen for the moment when Tait was present; now it was
on again, and he went forth to deceive the world. Yet he had an
uneasy consciousness that one man at least guessed his real
character.
He did not go direct home, as it was yet early, and he had one or
two things to do in connection with his new task. First he drove to
Tait's chambers, and ascertained from the porter that the two young
men were within.
"If it is the Lyceum you mean, sir, I have just got two stalls for Mr.
Tait."
"It has not had a pleasant effect on you," replied his wife, smiling;
"you do not look at all well."
"I am not well," said Hilliston, who merely trifled with his food;
"you must excuse me going with you to the Lamberts' to-night, as I
think I shall call in and see my doctor."
"I prefer going to see him, Louise. You will probably not be back
till three in the morning, so I will go to bed immediately on my
return. Have no fear, my dear, it is only a trifling indisposition."
Mrs. Bezel took little interest in these material comforts. Her life
was passed between a couch in the bow-window, a well-cushioned
chair by the fire, and a downy bed in the next room. She had little
appetite and did not enjoy her food; mental anxiety prevented her
interesting herself in the splendors around her; and the only
pleasure she took was her dreary journey in a Bath-chair when the
weather permitted. Then, as she inhaled the fresh breeze blowing
across the Heath, she gazed with longing eyes at London, almost
hidden under its foggy veil, far below, and always returned with
reluctance to the familiar splendors of her narrow dwelling. Fortune
had given her much, but by way of compensation had deprived her
of the two things she most desired—of health and of love.
Even on this warm June evening a fire burned in the grate, for
Mrs. Bezel was a chilly creature, who shrunk at the least breath of
wind. According to custom, she had left the window couch at seven
o'clock, and had taken her simple meal while seated in her large
chair to the right of the fireplace. After dinner she took up a novel
which was placed on a small table at her elbow, and tried to read;
but her attention was not fixed on the book, and gradually it fell
from her hands, while she gazed idly at the fire.
What she saw therein Heaven only knows. We all have our
moments of retrospection, and can picture the past in the burning
coals. Some even picture the future, but there was none for this
woman. She was old, weary, diseased, worn-out, and therefore saw
in the fire only the shadows of past years. Faces looked out of the
flaming valleys, scenes arranged themselves in the red confusion;
but among them all there was always one face, one scene, which
never vanished as did the others. This special face, this particular
scene, were fixed, immovable, cruel, and insistent.
The chime of the clock striking half-past nine roused her from her
reverie, and she again addressed herself to the novel with a sigh.
Tortured by her own thoughts, Mrs. Bezel was not accustomed to
retire before midnight, and there were nearly three hours to be got
through before that time. Her life was as dreary, and weary, and
heart-breaking as that of Mariana in the Moated Grange.
"I am the same as ever," she replied coldly, while he drew a chair
close to the fire, and stretched out his hands to the blaze. "Why
have you come here at this hour?"
"I think you can guess my errand," he said suavely. "It concerns
the letter you wrote to Claude Larcher."
"I have merely to inform you that the man whom you desire to
see is in London, and will no doubt answer your kind invitation in
person."
Mrs. Bezel stretched out her hand and selected a letter from the
little pile on her table.
"If you will look at that," she said coldly, "you will see that Claude
intends to call on me at three o'clock to-morrow."
"Ah, you would ruin me!" he cried, springing to his feet; "you
would drag up those follies of '66, and make London too hot to hold
me! Have I not implored, threatened, beseeched, commanded—
done everything in my power to make you hold your peace?
Miserable woman, would you drag the man you love down to——"
"Yes. It means ruin to us both. But the loss is yours, not mine.
Helpless and deserted, life has no further charms for me, but you,
Mr. Hilliston, doubtless feel differently."
"What harm!" she interrupted fiercely. "Have you not ruined me,
have you not deserted me, have you not robbed me of all that I
loved? My life has been one long agony, and you are to blame for it
all. Not a word," she continued imperiously. "I shall speak. I insist
upon your knowing the truth!"
"I loved you once, Francis. I loved you to my own cost. For your
sake I lost everything—position, home, respect, and love. And you—
what did you do?"
"Do you think I valued this splendor? I know well enough that you
gave me all material comforts. But I wanted more than this. I
wanted love."
"Aye! I had the passion such as you call love. Did it endure? You
know well that it did not. So long as I was healthy and handsome
and bright your attentions continued, but when I was reduced to this
state, ten years ago, what did you do? Left me to marry another
woman."
"And you did marry her, and no doubt neglect her as you do me.
Is Mrs. Hilliston any happier in her splendid house at Kensington
Gore than I in this miserable cottage? I think not. I waited and
waited, hoping your love would return. It did not; so I took my own
course—revenge!"
"Yes. Listen to me. I wrote the first letter on the impulse of the
moment. I had been reading a book called 'A Whim of Fate,' which
contained——"
"You must not—you dare not," said Hilliston, with dry lips. "It
means ruin!"
"Impossible," he said curtly. "Our relations are too close for one to
fall without the other."
"So you think," rejoined Mrs. Bezel coolly; "but I know how to
protect myself. And of one thing you may be assured, I will say
nothing against you. All I intend to do is to tell him of his father's
death."
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com