Karteikarten
Programming Languages - Chapter 6
Karten in diesem Stapel (41)
- 1Data types can be:Unstructured (also called scalar)
e.g., char, int, double
Structured
e.g., array, record - 2String Length OptionsStatic
Limited Dynamic
Dynamic - 3Limited Dynamic LengthA special character (null) is used to indicate the end of a string’s characters, rather than maintaining the length
- 4Dynamic LengthStrings have varying length with no maximum
- 5ArrayAn aggregate of homogeneous data elements in which an individual element is identified by its position in the aggregate, relative to the first element
- 6Categories of ArraysStatic
Fixed Stack-Dynamic
Fixed Heap-Dynamic
Heap Dynamic - 7Heap Dynamicsubscript range and storage bindings are dynamic and can change any number of times
- 8Fixed Heap-DynamicStorage binding is dynamic but fixed after allocation (i.e., binding is done when requested and storage is allocated from heap, not stack)
- 9Fixed Stack-DynamicRange of subscripts is statically bound, but storage is bound at declaration elaboration time
- 10StaticRange of subscripts and storage allocation are static
- 11Data TypeDefines a collection of data values and a set of predefined operations on those values
- 12Primitive Data TypesData types not defined in terms of other data types
- 13IntegerSupported directly by the hardware.
There may be as many as eight different integer types in a language. - 14DecimalFor business applications (money)
Stored in binary coded decimal (BCD)
Advantage: accuracy
Disadvantages: limited range, wastes memory - 15Typical String OperationsAssignment
Comparison (=, >, etc.)
Catenation
Substring reference
Pattern matching - 16DescriptorThe collection of the attributes of a variable
- 17Enumeration TypesOne in which the user enumerates all of the possible values, which are symbolic constants
- 18Advantage of Enumeration TypesReadability: no need to code a color as a number
Reliability: No enumeration variable can be assigned a value outside its defined range - 19IndexingA mapping from array indices to elements
- 20Slicesome substructure of an array
References part of an array as a unit - 21Access Functionmaps subscript expressions to an address in the array
- 22Associative Arrayan unordered collection of data elements that are indexed by an equal number of values called keys
- 23Recorda possibly heterogeneous aggregate of data elements in which the individual elements are identified by names
- 24Uniona type whose variables are allowed to store different type values at different times during execution
Discriminated unions include a tag to record the current type value
Free union has no type-checking (bad!) - 25PointerA type in which the variables have a range of values that consist of memory addresses and a special value, nil
- 26Two fundamental pointer operations:assignment and dereferencing
- 27Assignmentused to set a pointer variable’s value to some useful address
- 28Dereferencingyields the value stored at the location represented by the pointer’s value
- 29C++ Reference Typeconstant pointers that are implicitly dereferenced.
Used for parameter passing:
Advantages of both pass-by-reference and pass-by-value - 30Dangling PointerA pointer points to a heap-dynamic variable that has been deallocated
- 31Lost heap-dynamic variablesA heap-dynamic variable that is no longer referenced by any program pointer
- 32Solutions to Dangling Pointer problem:Tombstone
Locks and Keys - 33Tombstoneextra heap cell that is a pointer to the heap-dynamic variable
The actual pointer variable points only at tombstones. - 34Locks and KeysEvery access to the dereferenced pointer compares the key value of the pointer to the lock value in the heap-dynamic variable. It they match, the access is legal; otherwise, runtime error is generated
- 35Two approaches to reclaiming garbage:Reference counters (eager approach)
mark-sweep (lazy approach) - 36Mark SweepThe run-time system allocates storage cells as requested until the list of available space becomes empty; then a mark-sweep process is begun to gather all the garbage
- 37Reference Countermaintain a counter in every cell that stores the number of pointers currently pointing at the cell.
- 38Compatible Typeone that is either legal for the operator, or is allowed under language rules to be implicitly converted, by compiler-generated code, to a legal type. This automatic conversion is called a coercion
- 39Type Checkingthe activity of ensuring that the operands of an operator are of compatible types.
- 40Name Type Compatibilitymeans that two variables have compatible types if they are in either the same declaration or in declarations that use the same type name
- 41Structure Type Compatibilitymeans that two variables have compatible types if their types have identical structures
Informationen
- Beschreibung
- Karteikarten am Programming Languages - Chapter 6, erstellt von M KB am 26/02/2018.
- Erstellt von
- M KB
- Aufrufe
- 0
- Bewertung