Programming Languages Chapter 7

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/122

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

123 Terms

1
New cards

Language Reference Manual

Most common way to specify semantics. The expanding use of English descriptions suffer from the lack of precision and may have omissions and ambiguities

2
New cards

Defining Translator

Questions about a language can be answered by expirement. But cannot be answered in advance. Bugs and machine dependencies in the translator become parts of the language semantics. May not be portable to all machines

3
New cards

Formal definition

Formal, mathematical methods are precise, but are also complex and abstract, and require study to understand.

4
New cards

Denotational semantics

Semantics using a series of functions

5
New cards

names or identifiers

The most fundamental abstraction

6
New cards

Data type attribute and the value attribute

The variable name is assocaited with

7
New cards

Function, Numbers, Names, and Data Types. The body of code

Function name is associated with

8
New cards

Binding

The process of associated an attribute to a name

9
New cards

Static Binding

Occurs before execution (parsing, semantic analysis, linking, or loading) Compilers perform most this way

10
New cards

Dynamic Binding

Occurs during execution. Interpreters perform most bindings dynamically

11
New cards

Static attribute

Statically bound attributes

12
New cards

Dynamic attribute

Dynamically bound attributes

13
New cards

int x

The data type integer is bound to x statically

14
New cards

x = 2

The value 2 is bound to x dynamically

15
New cards

y = new int

A memory space is bound to *y dynamically and A memory address is bound to y dynamically

16
New cards

Language definition time

Predefined identifieres (bool, char, int, float)

17
New cards

Language implementation time

maxint, string::npos

18
New cards

Translation time (compile-time)

Data types of variable or constant names

19
New cards

Link time

Link a program with libraries

20
New cards

Load time

The location of global variables

21
New cards

Execution time (run-time)

Assign values to variables

22
New cards

implicitly or explicitly

Binding can be determined by a declaration either

23
New cards

explicitly bound

int x binding: x

24
New cards

implicitly bound

int x binding: location

25
New cards

Definitions

Declarations that specify all potential attributes. Function definitions

26
New cards

Simple declarations

Partially specifify attributes

27
New cards

Incomplete type

ifstream inFile. Other attributes are not provided in teh same program. The complete attributes can only be found at link time

28
New cards

Blocks

Consist of a sequence of declarations followed by a sequence of statements and surrounded by syntactic markers

29
New cards

Declarations

syntactically and semantically related to blocks

30
New cards

Local Declarations

Declared within blocks

31
New cards

Global (nonlocal) declarations

Declared outside any block

32
New cards

Scope of a Binding

The region of a program where the binding is maintained

33
New cards

Scope of a declaration

From the point right after the eclaration to the end of the block

34
New cards

Scope Holes

The declarations in inner blocks take precedence over declarations in outer blocks

35
New cards

Visibility of a Declaration

The regions of a program where the bindings of a declaration apply

36
New cards

may not be

The scope of a declaration _____ to the visibility of a declaration

37
New cards

Access hidden declarations

C++ (::) Ada (.)

38
New cards

Symbol Table

A function expressing the binding of attributes to names

39
New cards

add or delete bindings

Change with the proceeding of translation and execution to ________

40
New cards

Names ——————> Attributes

Graphical representation of a symbol table

41
New cards

Identifyer Dictionary

Support insertion, lookup, and deletion of bindings in declarations

42
New cards

On entry into a block

Process all declarations, add corresponding bindings to the symbol table

43
New cards

On exit from a block

Remove corresponding bindings from the symbol table

44
New cards

Static (lexical) scoping

Process declarations before execution

45
New cards

Dynamic Scoping

Process declarations as they are encountered along an execution path

46
New cards

Problems with Dynamic Scoping

The reference on nonlocal variables and datatype of nonlocal variables cannot be predicted before execution

47
New cards

Why use dynamic scoping

For highly dynamic interpreted languages, used in an interpreter

48
New cards

Local Symbol Table

Must contain a local symbol table as an attribute

49
New cards

Symbol Table for Struct Declaration

Must contain further declarations of its data fields. The declarations of data fields are accessible whenever the struct variable is in scope

50
New cards

Overloading

Use the same name to refer to different things in a program

51
New cards

The addition operator (+)

Integer addition and floating-point addition

52
New cards

Disambiguate overloading

C++ and Ada allow the overloading of both function names and operators. Java only allows the overloading of function names

53
New cards

Calling context

numbers and types of parameters

54
New cards

Ambiguous calling context

Depend on the language rules for converting a value from one type to another

55
New cards

Automatic Conversion

Ada and C++ no ____ is allowed

56
New cards

not lose information

In Java all conversions that do _____ are allowed

57
New cards

Complicate

Automatic conversions make overloading resolution ___

58
New cards

Return type and parameter names

Besides the number and types of the parameter values, Ada allowed for ___ to be used

59
New cards

ignore the

C++ and Java ___ the return type

60
New cards

built-in operators

Ada and C++ (not Java) allow ___ to be overloaded

61
New cards

Keep synatctic properties

Associativity and precedence

62
New cards

Operators and functions

No semantic difference. There is a syntactic difference

63
New cards

Name overloading

Reuse the same name for completely different things

64
New cards

Name Overloading not permitted

In most languages, can be extremely confusing and little benefits are gained

65
New cards

Limiting names and different symbol tables

Name overloading can be handy

66
New cards

Registers

A small, high-speed storage location within a CPU

67
New cards

Code Space

Instructions written in a programming language

68
New cards

Global Space

The area where variables and functions can be accessed from anywhere within a program

69
New cards

Stack

LIFO (Last-In, First-Out) structure used for managing local variables and function calls

70
New cards

Heap

a more flexible region for storing dynamically allocated memory

71
New cards

Allocation

Storage classes of variables

72
New cards

Static allocation

For global variables

73
New cards

Automatic allocation

For local variabls

74
New cards

Dynamic allocation

For heap allocation

75
New cards

Environment

Maintain the bindings of names to locations.

76
New cards

Statically (at load time) or dynamically (at execution time)

The environment may be constructed

77
New cards

FORTRAN

Use a completely static environment; all allocations are bound statically

78
New cards

LISP

Use a completly dynamic environment; all allocations are bound during execution

79
New cards

C, C++, Ada, and other Algol-style languages

In the middle; some allocation is performed statically while other allocation is performed dynamically

80
New cards

On entry into block

Bind locations to local variabls in a stack-based fashion.

81
New cards

Upside-down stack

Memory space

82
New cards

On exit from a block

Remove bindings of locations from variabls

83
New cards

Compile time quantities

Constant names and data types may be purely ___ in a compiled language

84
New cards

Statically

Global variables are allocated

85
New cards

Automatically

Local variables are allocated ____ when a block is being executed

86
New cards

Lifetime (extent) of an allocation

The duration of an allocation in the environment

87
New cards

Beyond

Can extend ___ the region where it may be accessed

88
New cards

Pointers

An object whose stored value is a reference to another object (Use dynamic allocation)

89
New cards

Dynamic Allocation in C++

Use the new operator for allocation; use the delete operator for deallocation

90
New cards

Dynamic Allocation in C

Use the malloc function for allocation; use the free function for deallocation

91
New cards

All functional languages

Require the heap to be completely automatic. With no allocation or deallocation under the programmer’s control

92
New cards

Allocation

Java allow ___, but not deallocation, to be udner the programmer control. Has no dereference operator

93
New cards

Specify a Storage Class

Some languages allow programmers to specify the kind of allocation within a declaration

94
New cards

Variables

Objects whoes stored value can change during execution

95
New cards

Box-and-circle diagram

To represent only the environment-related attributes. Name, location, and value only

96
New cards

R-value (right-hand side value)

The value stored in the location of a variable

97
New cards

L-value (left-hand side value)

The location of a variable

98
New cards

In ML

variables are explicitly specified as locations or references to values

99
New cards

Implicitly

In C/C++ specify locations and values __ Automatic dereferencing of l-values or r-values, such as the statement x = y;

100
New cards

Explicitly

In C/C++ specify location and values; use the address of the operator to get the l-value, use the deference operator to get the r-value