Lecture 4 Flashcards
What are variables in programming?
Variables are abstractions in a language for the memory cells of a machine.
What are the main attributes of a variable?
Type, Scope, Lifetime.
What are names associated with in programming?
Names are associated with subprograms, formal parameters, and other program constructs.
What is an Identifier?
Identifier is another term for a name.
What are some design issues for names?
Whether names are case sensitive and whether special words are reserved words or keywords.
What are the forms of names(name forms) in programming languages?
Names are strings of characters used to identify entities in a program, with different length limitations and naming conventions depending on the language.
What are common naming conventions?
Underscore characters and Camel notation.
What is the controversy around case sensitivity in programming languages?
Some believe it detracts from readability, while others do not see it as a problem.
What are special words in programming languages used for?
To make programs more readable and to separate syntactic parts of statements and programs.
What is the difference between a keyword and a reserved word?
A keyword is special only in certain contexts, while a reserved word cannot be used as a name.
What attributes characterize a variable?
Name, address, type, lifetime, and scope.
What is the address of a variable?
The machine memory address associated with the variable.
What are aliases?
When more than one variable name can access the same memory location.
What does the type of a variable determine?
The type determines the set of values the variable can store and the operations that can be performed on those values.
What is the value of a variable?
The contents of the memory cell(s) associated with the variable.
What is binding in programming?
The association between an attribute and an entity.
When can binding occur?
Language design time, implementation time, compile time, load time, link time, and run time.
What is static binding?
Binding that occurs before run time and remains unchanged during program execution.
What is dynamic binding?
Binding that occurs during run time or can change during program execution.
What must happen before a variable can be referenced in a program?
It must be bound to a data type.
What are explicit and implicit declarations in static type binding?
Explicit declaration specifies variable names and types; implicit declaration uses default conventions to associate variables with types.
What is dynamic type binding?
The type of a variable is bound when it is assigned a value in an assignment statement.
What is an advantage of dynamic type binding?
Provides more programming flexibility.
What is a disadvantage of dynamic type binding?
It diminishes the error-detection capability of the compiler and requires run-time type checking.
What is allocation in the context of storage bindings?
The process of taking memory cells from a pool of available memory.
What is deallocation?
Returning a memory cell to the pool of available memory after it is unbound from a variable.
What is the lifetime of a variable?
The time during which a variable is bound to a specific memory location.
What are static variables?
Variables bound to memory cells before program execution begins and remain bound until program termination.
What are stack-dynamic variables?
Variables whose storage bindings are created when their declaration statements are elaborated during run time.
What is an advantage of implicit heap-dynamic variables?
High flexibility and the ability to write highly generic code.
What are explicit heap-dynamic variables?
Nameless memory cells allocated and deallocated by explicit run-time instructions, referenced through pointers or reference variables.
What are implicit heap-dynamic variables?
Variables bound to heap storage only when assigned values, with all attributes bound at each assignment.
What is a disadvantage of implicit heap-dynamic variables?
Run-time overhead for maintaining dynamic attributes and loss of some compiler error detection.
In what way are reserved words better than keywords?
Compile time, load time, link time, and run time.
Define binding and binding time.
Binding is the association between an attribute and an entity, and binding time is when this association occurs.