Index

Note: Page numbers followed by f and t indicate figures and tables respectively.

A

abstract data type (ADT), 337, 366

abstract syntax, 356359

programming exercises for, 364365

representation in Python, 372373

abstract-syntax tree, 115

for arguments lists, 401403

for Camille, 359

parser generator with tree builder, 360364

programming exercises for, 364365

TreeNode, 359360

abstraction, 104

binary search, 151152

binary tree, 150151

building blocks as, 174175

programming exercises for, 152153

activation record, 201

actual parameters, 131

ad hoc binding, 236238

ad hoc polymorphism. See overloading;

operator/function

overloading

addcf function, 298

ADT. See abstract data type (ADT)

aggregate data types

arrays, 338

discriminated unions, 343

programming exercises for, 343344

records, 338340

undiscriminated unions, 341343

agile methods, 25

all-or-nothing proposition, 613614

alphabet, 34

ambiguity, 52

ambiguous grammar, 51

ancestor blocks, 190

antecedent, definition of, 651

ANTLR (ANother Tool for Language Recognition), 81

append, primitive nature of, 675676

applicative-order evaluation, 493, 512

apply_environment_reference function, 462

arguments. See actual parameters Armstrong, Joe, 178

arrays, 338

assembler, 106

assignment statement, 457458

conceptual and programming exercises for, 465467

environment, 462463

illustration of pass-by-value in Camille, 459460

reference data type, 460461

stack object, 463465

use of nested lets to simulate sequential evaluation, 458459

associativity, 50

of operators, 5758

asynchronous callbacks, 620

atom?, list-of-atoms?, and list-of-numbers?, 153154

atomic proposition, 642

attribute grammar, 66

automobile concepts, 7

B

backtracking, 651

Backus–Naur Form (BNF), 4041

backward chaining, 659660

balanced pairs of lexemes, 43

bash script, 404

β-reduction, 492495

examples of, 495499

biconditional, 644

binary search tree abstraction, 151152

binary tree abstraction, 150151

binary tree example, 667672

binding and scope

deep, shallow, and ad hoc binding, 233234

ad hoc binding, 236238

conceptual exercises for, 239240

deep binding, 234235

programming exercises for, 240

shallow binding, 235236

dynamic scoping, 200202

vs. static scoping, 202207

free or bound variables, 196198

programming exercises for, 198199

FUNARG problem, 213214

addressing, 226228

closures vs. scope, 224225

conceptual exercises for, 228

downward, 214

programming exercises for, 228233

upward, 215224

upward and downward FUNARG problem in single function, 225226

uses of closures, 225

introduction, 186187

lexical addressing, 193194

conceptual exercises for, 194195

programming exercise for, 195

mixing lexically and

dynamically scoped

variables, 207211

conceptual and programming exercises for, 211213

preliminaries

closure, 186

static vis-à-vis dynamic properties, 186

static scoping

conceptual exercises for, 192193

lexical scoping, 187192

vs. dynamic scoping, 202207

bindings times, 67

block-structured language, 188

Blub Paradox, 21

BNF. See Backus–Naur Form (BNF)

bootstrapping a language, 540

bottom-up parser, 75, 8081

bottom-up parsing, 48

bottom-up programming, 1516, 177, 716717

bottom-up style of programming, 540

bound variables, 196198. See also formal parameters

programming exercises for, 198199

breakpoints, 560562

built-in functions, in Haskell, 301307

C

C language, 105106

call chain, 200

call-with-current-continuation, 550554

callbacks, 618620

call/cc, defining, 622625

call/cc vis-à-vis CPS, 617618

Camille, 8689

adding support for

recursion in, 440441

for user-defined functions to, 423426

assignment statement in, 457458

implementing

pass-by-name/need in, 522526

programming exercises for, 526527

pass-by-value in, 459460

properties of new versions of, 465t

sequential execution in, 527532

programming exercise for, 533

Camille abstract-syntax tree for, 359

data type: TreeNode, 359360

parser generator with tree builder, 360364

programming exercises for, 364365

Camille interpreter, 533537

conceptual and programming exercises for, 537539

implementing

pass-by-reference in, 485

programming exercise for, 490492

reimplementation of

evaluate_operand

function, 487490

revised implementation of

references, 486487

candidate sentences, 34

capability to impart control, 701

category theory, 385

choices of representation, 367

Chomsky hierarchy, 41

class constraint, 257

clausal form, 651653

resolution with propositions in, 657660

CLIPS programming language, 14, 705

asserting facts and rules, 705706

conditional facts in rules, 708

programming exercises for, 708709

templates, 707

variables, 706707

Clojure, 116

closed-world assumption, 701

closure, 186

non-recursive functions, 426427

representation

in Python, 371372

of recursive environment, 442

in Scheme, 367371

uses of, 225

vs. scope, 224225

CNF. See conjunctive normal form (CNF)

code indentation, 727

coercion, 249

combining function, 319

Common Lisp, 128

compilation, 106

low-level view of execution by, 110f

compile time, 6

compiler, 194

compiler translates, 104

advantages and disadvantages of, 115t

vs. interpreters, 114115

complete function application, 286

complete graph, 680

complete recursive-descent parser, 7679

compound propositions, 642

compound term, 645

concepts, relationship of, 714715

concrete syntax, 356

representation, 74

concrete2abstract function, 358

conjunctive normal form (CNF), 646648

cons cells, 135136

conceptual exercise for, 141

list-box diagrams, 136140

list representation, 136

consequent, definition of, 651

constant function, 130

constructor, 352

context-free languages and, 4244

context-sensitive grammar, 6467

conceptual exercises for, 67

continuation-passing style (CPS)

all-or-nothing proposition, 613614

call/cc vis-à-vis CPS, 617618

growing stack or growing continuation, 610613

introduction, 608610

trade-off between time and space complexity, 614617

transformation, 620622

conceptual exercises for, 625626

defining call/cc in, 622625

programming exercises for, 626635

control abstraction, 585586

applications of first-class continuations, 589

conceptual exercises for, 591593

coroutines, 586589

power of first-class continuations, 590

programming exercises for, 593594

control and exception handling, 547

callbacks, 618620

continuation-passing style

all-or-nothing proposition, 613614

call/cc vis-à-vis CPS, 617618

growing stack or growing continuation, 610613

introduction, 608610

trade-off between time and space complexity, 614617

transformation, 620635

control abstraction, 585586

applications of first-class continuations, 589

conceptual exercises for, 591593

coroutines, 586589

power of first-class continuations, 590

programming exercises for, 593594

first-class continuations

call/cc, 550554

concept of continuation, 548549

conceptual exercises for, 554555

programming exercises for, 555556

global transfer of control with

breakpoints, 560562

conceptual exercises for, 564565

first-class continuations in Ruby, 562563

nonlocal exits, 556560

other mechanisms for, 570579

programming exercises for, 565570

levels of exception handling in programming languages, 579

dynamically scoped exceptions, 582583

first-class continuations, 583584

function calls, 580581

lexically scoped exceptions, 581

programming exercises for, 584585

stack unwinding/crawling, 581582

tail recursion

iterative control behavior, 596598, 596f

programming exercises for, 606608

recursive control behavior, 594595

space complexity and lazy evaluation, 601606

tail-call optimization, 598600

coroutines, 586589

CPS. See continuation-passing style (CPS)

curried form, 292294

currying

all built-in functions in Haskell are, 301307

conceptual exercises for, 310311

curried form, 292294

flexibility in, 297301

form through first-class closures, 307308

ML analogs, 308310

partial function application, 285292

programming exercises for, 311313

and uncurry functions in Haskell, 295297

and uncurrying, 294295

D

dangling else problem, 5860

data abstraction, 337338

abstract syntax, 356359

programming exercises for, 364365

abstract-syntax tree for Camille, 359

Camille abstract-syntax tree data type: TreeNode, 359360

Camille parser generator with tree builder, 360364

programming exercises for, 364365

aggregate data types

arrays, 338

discriminated unions, 343

programming exercises for, 343344

records, 338340

undiscriminated unions, 341343

case study, 366367

abstract-syntax representation in Python, 372373

choices of representation, 367

closure representation in Python, 371372

closure representation in Scheme, 367371

programming exercises for, 373382

conception and use of data structure, 366

inductive data types, 344347

ML and Haskell

analysis, 385

applications, 383385

comparison of, 383

summaries, 382383

variant records, 347348

in Haskell, 348352

programming exercises for, 354356

in Scheme, 352354

decision trees, 710

declaration position, 193

declarative programming, 1315

deduction theorem, 644

deep binding, 234235

deferred callback, 620

defined language vis-à-vis defining language, 395

defined programming language, 115, 395

delay function, 504

denotation, 186

denotational construct, 37, 39

denoted value, 345

dereference function, 461, 522

difference lists technique, 144146

discriminated unions, 343

docstrings, 728

domain-specific language, 15

dot notation, 136

downward FUNARG problem, 214

in single function, 225226

DrRacket IDE, 352

Dyck language, 43

dynamic binding, 67

dynamic scoping, 200202

advantages and disadvantages of, 203t

vs. static scoping, 202207

dynamic semantics, 67

dynamic type system, 245

dynamically scoped exceptions, 582583

E

eager evaluation, 493

EBNF. See Extended

Backus–Naur Form (EBNF)

embedded specific language, 15

empty string, 34

entailment, 643

environment, 366382, 441445, 462463

environment frame. See activation record

Erlang, 178

evaluate-expression

function, 393

evaluate_expr function, 427430, 445446

evaluate_operand function, reimplementation of, 487490

execute_stmt function, 532

expert system, 705

explicit conversion, 252

explicit/implicit typing, 268

expressed values vis-à-vis denoted values, 394395

Extended Backus–Naur Form (EBNF), 45, 6061

conceptual exercises for, 6164

external representation, 356

F

fact, 656

factorial function, 610

fifth-generation languages. See logic programming;

declarative programming

finite-state automaton (FSA), 3839, 73, 74f

two-dimensional array modeling, 75t

first Camille interpreter

abstract-syntax trees for arguments lists, 401403

front end for, 396399

how to run Camille program, 404405

read-eval-print loop, 403404

simple interpreter for, 399401

first-class closures, supporting curried form through, 307308

first-class continuations

applications of, 589

call/cc, 550554

concept of continuation, 548549

conceptual exercises for, 554555

levels of exception handling in

programming languages, 583584

power of, 590

programming exercises for, 555556

in Ruby, 562563

first-class entity, 11, 126

first-order predicate calculus, 14, 644645

conjunctive normal form, 646648

representing knowledge as predicates, 645646

fixed-format languages, 72

fixed point, 505

fixed-point Y combinator, 714

folding function, 319

folding lists, 319324

foldl vis-à-vis foldr, 323324

in Haskell, 319320

in ML, 320323

foldl, use of, 606

foldl’, use of, 606

foldr, use of, 606

formal grammar, 40

formal languages, 3435

formal parameters, 131

formalism gone awry, 660

Fortran, 22

forward chaining, 649, 657, 660

fourth-generation languages, 81

free-format languages, 72

free or bound variables, 196198

programming exercises for, 198199

free variables, 196198

programming exercises for, 198199

fromRational function, 257

front end, 73

for Camille, 396399

source code, 394

FSA. See finite-state automaton (FSA)

full FUNARG programming language, 226

FUNARG problem, 213214

addressing, 226228

closures vs. scope, 224225

conceptual exercises for, 228

downward, 214

in single function, 225226

programming exercises for, 228233

upward, 215224

in single function, 225226

uses of closures, 225

function annotations, 738

function calls, 580581

function currying, 155

function hiding. See function overriding

function overloading, 738

function overriding, 267268

functional composition, 315316

functional mapping, 313315

functional programming, 1112

advanced techniques

eliminating expression recomputation, 167

more list functions, 166167

programming exercises for, 170174

repassing constant arguments across recursive calls, 167170

binary search tree abstraction, 151152

binary tree abstraction, 150151

concurrency, 177178

cons cells, 135136

conceptual exercise for, 141

list-box diagrams, 136140

list representation, 136

functions on lists

append and reverse, 141144

difference lists technique, 144146

list length function, 141

programming exercises for, 146149

hallmarks of, 126

lambda calculus, 126127

languages and software engineering, 174

building blocks as abstractions, 174175

language flexibility supports program modification, 175

malleable program design, 175

prototype to product, 175176

layers of, 176177

Lisp

introduction, 128

lists in, 128129

lists in, 127128

local binding

conceptual exercises for, 164

let and let* expressions, 156158

letrec expression, 158

programming exercises for, 164165

using let and letrec to define, 158161

other languages supporting, 161164

programming project for, 178179

recursive-descent parsers, Scheme predicates as, 153

atom?, list-of-atoms?, and list-of-numbers?, 153154

list-of pattern, 154156

programming exercise for, 156

Scheme

conceptual exercise for, 134

homoiconicity, 133134

interactive and illustrative session with, 129133

programming exercises for, 134135

functions, 126

non-recursive functions adding support for user-defined functions to Camille, 423426

augmenting

evaluate_expr

function, 427430

closures, 426427

conceptual exercises for, 431432

programming exercises for, 432440

simple stack object, 430431

recursive functions

adding support for recursion in Camille, 440441

augmenting

evaluate_expr with new variants, 445446

conceptual exercises for, 446447

programming exercises for, 447450

recursive environment, 441445

functions on lists

append and reverse, 141144

difference lists technique, 144146

list length function, 141

programming exercises for, 146149

functor, 645

G

generate-filter style of programming, 507

generative construct, 41

global transfer of control

with continuations

breakpoints, 560562

conceptual exercises for, 564565

first-class continuations in Ruby, 562563

nonlocal exits, 556560

programming exercises for, 565570

other mechanisms for, 570

conceptual exercises for, 578

goto statement, 570571

programming exercises for, 578579

setjmp and longjmp, 571578

goal. See headless Horn clause

goto statement, 570571

grammars, 4041

conceptual exercises for, 6164

context-free languages and, 4244

disambiguation

associativity of operators, 5758

classical dangling else problem, 5860

operator precedence, 57

generate sentences from, 4446

language recognition, 46f, 4748

regular, 4142

growing continuation, 610613

growing stack, 610613

H

handle, 48

hardware description languages, 17

Haskell languages, 162, 258259

all built-in functions in, 301307

analysis, 385

applications, 383385

comparison of, 383

curry and uncurry functions in, 295297

folding lists in, 319

sections in, 316319

summaries, 382383

variant records in, 348352

headed Horn clause, 653, 656

headless Horn clause, 653, 656, 665

heterogeneous lists, 128

higher-order functions (HOFs), 155, 716

analysis, 334335

conceptual exercises for, 329330

crafting cleverly conceived functions with curried, 324328

folding lists, 319324

functional composition, 315316

functional mapping, 313315

programming exercises for, 330334

sections in Haskell, 316319

Hindley–Milner algorithm, 270

HOFs. See higher-order functions (HOFs)

homoiconic language, 133, 540

homoiconicity, 133134

Horn clauses, 653654

limited expressivity of, 702

in Prolog syntax, casting, 663

host language, 115

hybrid language

implementations, 109

hybrid systems, 112

hypothesis, 656

I

imperative programming, 10

implication function, 643

implicit conversion, 248252

implicit currying, 301

implicit typing, 268

implode function, 325326

independent set, 680

inductive data types, 344347

instance variables, 216

instantiation, 651

interactive or incremental testing, 146

interactive top-level. See read-eval-print loop

interface polymorphism, 267

interpretation vis-à-vis compilation, 103109

interpreter, 103

advantages and disadvantages of, 115t

vs. compilers, 114115

introspection, 703

iterative control behavior, 596598, 596f

J

JIT. See Just-in-Time (JIT) implementations

join functions, 728

Just-in-Time (JIT)

implementations, 111

K

keyword arguments, 735737

Kleene closure operator, 34

L

LALR(1) parsers, 90

lambda (λ) calculus, 11, 126127

abstract syntax, 356359

scope rule for, 187188

lambda functions, 738739

Python primer, 738739

Language-INtegrated Queries (LINQ), 18

languages

defined, 4

definition time, 6

development, factors

influencing, 2125

generator, 7980

implementation time, 6

and software engineering, 174

building blocks as abstractions, 174175

language flexibility supports program modification, 175

malleable program design, 175

prototype to product, 175176

themes revisited, 714

late binding. See dynamic binding

LATEX compiler, 106

lazy evaluation, 160

analysis of, 511512

applications of, 511

β-reduction, 492495

C macros to demonstrate pass-by-name, 495499

conceptual exercises for, 513517

enables list comprehensions, 506511

implementing, 501505

introduction, 492

programming exercises for, 517522

purity and consistency, 512513

tail recursion, 601606

two implementations of, 499501

learning language concepts, through interpreters, 393394

left-linear grammars, 41

leftmost derivation, 45

length function, 141

let expressions, 156158

let* expressions, 156158

letrec expression, 158

lexemes, 40, 72

lexical addressing, 193194

conceptual exercises for, 194195

programming exercise for, 195

lexical analysis, 72

lexical closures, 716, 739740

lexical depth, 193

lexical scoping, 187192, 425

and dynamically scoped variables, 207211

exceptions, 581

linear grammar, 41

link time, 6

LINQ. See Language-INtegrated Queries (LINQ)

Lisp, 11, 176

introduction, 128

lists in, 128129

list-and-symbol representation.

See S-expression

list-box diagrams, 136140

list-of pattern, 154156

list-of-vectors representation (LOVR), 379

lists

comprehensions, lazy evaluation, 506511

in functional programming, 127

functions

append and reverse, 141144

difference lists technique, 144146

list length function, 141

programming exercises for, 146149

in Lisp, 128129

and pattern matching in, 672674

predicates in Prolog, 674675

Python primer, 731733

representation, 136

literal function, 130

literate programming, 23

load time, 6

local binding

conceptual exercises for, 164

and conditional evaluation

Camille grammar and language, 395396

checkpoint, 391393

conditional evaluation in Camille, 410411

first Camille interpreter, 396405

interpreter essentials, 394395

learning language concepts

through interpreters, 393394

programming exercises for, 417419

putting it all together, 411417

syntactic and operational support for local binding, 405410

let and let* expressions, 156158

letrec expression, 158

other languages supporting, 161164

programming exercises for, 164165

Python primer, 742

using let and letrec to define, 158161

local block, 190

local reference, 190

logic programming analysis of Prolog

metacircularProlog

interpreter and WAM, 704705

Prolog vis-à-vis predicate

calculus, 701703

reflection in, 703704

applications of decision trees, 710

natural language processing, 709

CLIPS programming language, 705

asserting facts and rules, 705706

conditional facts in rules, 708

programming exercises for, 708709

templates, 707

variables, 706707

first-order predicate calculus, 644645

conjunctive normal form, 646648

representing knowledge as predicates, 645646

imparting more control in, 691697

conceptual exercises for, 697698

programming exercises for, 698701

introduction, 641642

from predicate calculus to

clausal form, 651653

conversion examples, 654656

formalism gone awry, 660

Horn clauses, 653654

motif of, 656

resolution with propositions in clausal form, 657660

Prolog programming language, 660662

analogs between Prolog and RDBMS, 681685

arithmetic in, 677678

asserting facts and rules, 662663

casting Horn clauses in Prolog syntax, 663

conceptual exercises for, 685686

graphs, 679681

list predicates in, 674675

lists and pattern matching in, 672674

negation as failure in, 678679

primitive nature of append, 675676

program control in, 667672

programming exercises for, 686691

resolution, unification, and instantiation, 665667

running and interacting with, 663665

tracing resolution process, 676677

propositional calculus, 642644

resolution

in predicate calculus, 649651

in propositional calculus, 648649

logical equivalence, 644

logician Haskell Curry, 292

LOVR. See list-of-vectors

representation (LOVR)

M

macros, 716

operator, 176

malleable program design, 175

manifest typing, 132. See also implicit typing

Match-Resolve-Act cycle, 705

memoized lazy evaluation. See pass-by-need

Mercury programming language, 14

mergesort function, 744748

metacharacters, 36

metacircular interpreters, 539540, 704705

programming exercise for, 540542

MetaLanguage (ML), 36, 162

analogs, 308310

analysis, 385

applications, 383385

comparison of, 383

summaries, 382383

metaphor, 24

metaprogramming, 716

ML. See MetaLanguage (ML)

modus ponens, 648

monomorphic, 253

multi-line comments, Python, 727

mutual recursion, Python

primer, 744

N

named keyword arguments, 735737

natural language processing, 709

nested functions, Python primer, 743

nested lets, to simulate sequential evaluation, 458459

non-recursive functions

adding support for user-defined functions to Camille, 423426

augmenting evaluate_expr function, 427430

closures, 426427

conceptual exercises for, 431432

programming exercises for, 432440

simple stack object, 430431

non-terminal alphabet, 40

nonfunctional requirements, 19

nonlocal exits, 553, 556560

normal-order evaluation, 493

ntExpressionList variant, 402

O

object-oriented programming in, 1213, 748750

occurs-bound?, 197198

occurs-free?, 197198

operational semantics, 19

operator precedence, 57

operator/function overloading, 263267

overloading, 258

P

palindromes, 34

papply function, 288

parameter passing

assignment statement, 457458

conceptual and programming exercises for, 465467

environment, 462463

illustration of pass-by-value in Camille, 459460

reference data type, 460461

stack object, 463465

use of nested lets to simulate sequential evaluation, 458459

Camille interpreters, 533537

conceptual and programming exercises for, 537539

implementing

pass-by-name/need in

Camille, 522526

programming exercises for, 526527

implementing

pass-by-reference in Camille

interpreter, 485

programming exercise for, 490492

reimplementation of

evaluate_operand function, 487490

revised implementation of references, 486487

lazy evaluation

analysis of, 511512

applications of, 511

β-reduction, 492495

C macros to demonstrate pass-by-name, 495499

conceptual exercises for, 513517

enables list comprehensions, 506511

implementing, 501505

introduction, 492

programming exercises for, 517522

purity and consistency, 512513

two implementations of, 499501

metacircular interpreters, 539540

programming exercise for, 540542

sequential execution in Camille, 527532

programming exercise for, 533

survey of

conceptual exercises for, 482484

pass-by-reference, 472477

pass-by-result, 477478

pass-by-value, 467472

pass-by-value-result, 478480

programming exercises for, 484485

summary, 481482

parametric polymorphism, 253262

parse trees, 5156

parser, 258

parser generator, 81

parsing, 46f, 4748, 7476

bottom-up, shift-reduce, 8082

complete example in lex and yacc, 8284

conceptual exercises for, 90

infuse semantics into, 50

programming exercises for, 90100

Python lex-yacc, 84

Camille scanner and parser generators in, 8689

complete example in, 8486

recursive-descent, 76

complete recursive-descent parser, 7679

language generator, 7980

top-down vis-à-vis bottom-up, 8990

partial argument application. See partial function application

partial function application, 285292

partial function instantiation. See partial function application

pass-by-copy, 144. See also pass-by-value

pass-by-name, 499500

C macros to demonstrate, 495499

implementing in Camille, 522526

programming exercises for, 526527

pass-by-need, 499500

implementing in Camille, 522526

programming exercises for, 526527

pass-by-reference, 472477

pass-by-result, 477478

pass-by-sharing, 471

pass-by-value, 459460, 467472

pass-by-value-result, 478480

pattern-directed invocation, 17

Perl, 207

program demonstrating dynamic scoping, 208

whose run-time call chain depends on its input, 210

+ operator, 36

polymorphic, 144, 253

polysemes, 55, 56t

positional vis-à-vis keyword arguments, 735738

pow function, 131

powerset function, 327328

powucf function, 293

precedence, 50

predicate calculus

to logic programming

clausal form, 651653

conversion examples, 654656

formalism gone awry, 660

Horn clauses, 653654

motif of, 656

resolution with propositions in clausal form, 657660

representing knowledge as, 645646

resolution in, 649651

vis-à-vis predicate calculus, 701703

primitive car, 142

primitive cdr, 142

primitive cons, 142

problem solving, thought process for, 2021

procedure, 126

program-compile-debug-recompile loop, 175

program, definition of, 4

programming language

bindings, 67

concept, 45, 78

concepts, 78

definition of, 4

features of type systems used in, 248t

fundamental questions, 46

implementation

influence of language goals on, 116

interpretation vis-à-vis compilation, 103109

interpreters and compilers, comparison of, 114115

programming exercises for, 117121

run-time systems, 109114

levels of exception handling in, 579

dynamically scoped exceptions, 582583

first-class continuations, 583584

function calls, 580581

lexically scoped exceptions, 581

programming exercises for, 584585

stack unwinding/crawling, 581582

recurring themes in, 2526

scope rules of, 187

programming styles

bottom-up programming, 1516

functional programming, 1112

imperative programming, 810

language evaluation criteria, 1920

logic/declarative

programming, 1315

object-oriented programming, 1213

synthesis, 1619

thought process for problem solving, 2021

Prolog programming language, 14, 660662

analysis of metacircularProlog interpreter and WAM, 704705

Prolog vis-à-vis predicate calculus, 701703

reflection in, 703704

arithmetic in, 677678

asserting facts and rules, 662663

casting Horn clauses in Prolog syntax, 663

conceptual exercises for, 685686

graphs, 679681

imparting more control in, 691697

conceptual exercises for, 697698

programming exercises for, 698701

list predicates in, 674675

lists and pattern matching in, 672674

negation as failure in, 678679

primitive nature of append, 675676

program control in, 667672

programming exercises for, 686691

and RDBMS, analogs between, 681685

resolution, unification, and

instantiation, 665667

running and interacting with, 663665

tracing resolution process, 676677

promise, 501

proof by refutation, 649

propositional calculus, 642644

resolution in, 648649

pure interpretation, 112

purity, concept of, 12

pushdown automata, 43

Python, 19

abstract-syntax representation in, 372373

closure data type in, 426

closure representation in, 371372

FUNARG problem, 222

lex-yacc, 84

Camille scanner and parser generators in, 8689

complete example in, 8486

Python primer

data types, 722725

essential operators and expressions, 725731

exception handling, 750751

introduction, 722

lists, 731733

object-oriented programming in, 748750

overview, 721722

programming exercises for, 751754

tuples, 733734

user-defined functions

lambda functions, 738739

lexical closures, 739740

local binding and nested functions, 742743

mergesort, 744748

more user-defined functions, 740742

mutual recursion, 744

positional vis-à-vis keyword arguments, 735738

simple user-defined functions, 734735

Q

qualified type or constrained type, 257

R

Racket programming language, 128

RDBMS. See relational database management system (RDBMS)

read-eval-print loop (REPL), 130, 175, 394, 403404

read-only reflection, 703

records, 338340

recurring themes in study of languages, 2527

recursive-control behavior, 143, 594595

recursive-descent parsers

Scheme predicates as, 153

atom?, list-of-atoms?, and list-of-numbers?, 153154

list-of pattern, 154156

programming exercise for, 156

recursive-descent parsing, 48, 76

complete recursive-descent parser, 7679

language generator, 7980

recursive environment

abstract-syntax representation of, 443444

list-of-lists representation of, 444445

recursive functions

adding support for recursion in Camille, 440441

augmenting evaluate_expr with new variants, 445446

conceptual exercises for, 446447

programming exercises for, 447450

recursive environment, 441445

reduce-reduce conflict, 51

reducing, 48

reference data type, 460461

referencing environment, 130, 366

referential transparency, 10

regular expressions, 3538

conceptual exercises for, 3940

regular grammars, 4142

regular language, 39

conceptual exercises for, 3940

relational database management

system (RDBMS), analogs

between Prolog and, 681685

REPL. See read-eval-print loop (REPL)

representation

abstract-syntax representation in Python, 372373

choices of, 367

closure representation in Python, 371372

closure representation in Scheme, 367371

resolution, 383

in predicate calculus, 649651

proof by contradiction, 659

in propositional calculus, 648649

resumable exceptions, 583

resumable semantics, 583

Rete Algorithm, 705

revised implementation of references, 486487

ribcage representation, 377

right-linear grammar, 41

rightmost derivation, 46

Ruby

first-class continuations in, 562563

Scheme implementation of coroutines, 588589

rule of detachment, 648

run-time complexity, 141144

run-time systems, 109114

S

S-expression, 129, 356357

same-fringe problem, 511

Sapir–Whorf hypothesis, 5

scanning, 7274

conceptual exercises for, 90

programming exercises for, 90100

Scheme programming language, 540

closure representation in, 367371

conceptual exercise for, 134

homoiconicity, 133134

interactive and illustrative session with, 129133

programming exercises for, 134135

variable-length argument lists in, 274278

variant records in, 352354

Schönfinkel, Moses, 292

scope, closure vs., 224225

scripting languages, 17

self-interpreter, 539

semantics, 6467

conceptual exercises for, 67

consequence, 643

in syntax, modeling some, 4951

sentence derivations, 4446

sentence validity, 34

sentential form, 44

sequential execution, in Camille, 527532

programming exercise for, 533

set-builder notation, 507

set-former, 507

setjmp and longjmp, 571578

shallow binding, 235236

shift-reduce conflict, 51

shift-reduce parsers, 81

shift-reduce parsing, 48

short-circuit evaluation, 492

side effect, 7

Sieve of Eratosthenes algorithm, 507

simple interpreter for Camille, 399401

simple stack object, 430431

simple user-defined functions, Python primer, 734735

simulated-pass-by-reference, 475

single-line comments, Python, 727

single list argument, 276

SLLGEN, 354

Smalltalk programming language, 1213, 225

sortedElem function, 507

space complexity

tail recursion, 601606

trade-off between time and, 614617

split functions, 728

SQL query, 14

square function, 499

stack frame. See activation record

stack object, 463465. See also simple stack object

stack of interpreted software interpreters, 112

stack unwinding/crawling, 581582

static bindings, 6, 116

static call graph, 200

static scoping

advantages and disadvantages of, 203t

conceptual exercises for, 192193

lexical scoping, 187192

vs. dynamic scoping, 202207

static semantics, 67

static type system, 245

static vis-à-vis dynamic properties, 186, 188t

static/dynamic typing, 268

string, 34

string2int function, 326327

struct. See records

SWI-Prolog, 663

symbol table, 194

symbolic logic, 642

syntactic ambiguity, 4849

conceptual exercises for, 6164

modeling some semantics in, 4951

parse trees, 5156

syntactic analysis. See parsing

syntatic sugar, 45

syntax, 34

T

table-driven, top-down parser, 75

tail-call optimization, 598600

tail recursion

iterative control behavior, 596598, 596f

programming exercises for, 606608

recursive control behavior, 594595

space complexity and lazy evaluation, 601606

tail-call optimization, 598600

tautology, 644

terminals, 40

terminating semantics, 582

terms, definition of, 651

throwaway prototype, 22, 176

thunk, 501505

time and space complexity, trade-off between, 614617

top-down parser, 75

top-down parsing, 48

top-down vis-à-vis bottom-up parsing, 8990

traditional compilation, 112

TreeNode, 359360

tuples, 275, 338

Python primer, 733734

Turing-complete. See programming language

Turing machine, 5

type cast, 252

type checking, 246248

type class, 257

type inference, 268274

type signatures, 310

type systems

conceptual exercises for, 278280

conversion, coercion, and casting

conversion functions, 252253

explicit conversion, 252

implicit conversion, 248252

function overriding, 267268

inference, 268274

introduction, 245246

operator/function overloading, 263267

parametric polymorphism, 253262

static/dynamic typing vis-à-vis explicit/implicit typing, 268

type checking, 246248

variable-length argument lists in Scheme, 274278

U

undiscriminated unions, 341343

unification, 651

UNIX shell scripts, 116

unnamed keyword arguments, 735737

upward FUNARG problem, 215224

in single function, 225226

user-defined functions

Python primer

lambda functions, 738739

lexical closures, 739740

local binding and nested functions, 742743

mergesort, 744748

more user-defined functions, 740742

mutual recursion, 744

positional vis-à-vis keyword arguments, 735738

simple user-defined functions, 734735

V

variable assignment, 458

variable-length argument lists, in Scheme, 274278

variadic function, 275

variant records, 347348

in Haskell, 348352

programming exercises for, 354356

in Scheme, 352354

very-high-level languages. See logic programming, declarative programming

virtual machine, 109

von Neumann architecture, 7

W

WAM. See Warren Abstract Machine (WAM)

Warren Abstract Machine (WAM), 705

weakly typed languages, 247

web browsers, 106

web frameworks, 17

well-formed formulas (wffs), 646

wffs. See well-formed formulas (wffs)

Y

Y combinatory, 159

yacc parser generator, 81

shift-reduce, bottom-up parser, 8284

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.66.128