Presentation is loading. Please wait.

Presentation is loading. Please wait.

Types and Related Issues

Similar presentations


Presentation on theme: "Types and Related Issues"— Presentation transcript:

1 Types and Related Issues
Bindings

2 Bindings Are factors that characterize objects name location value
type scope lifetime

3 Bindings (continued) Can be static or dynamic
Can occur at many different times: language design operator symbols to operations language implementation range of values for integers compile variable to type link call to library subprogram load static variables to memory cells run value to variable

4 Names

5 Names Format Aliasing length character set case
reserved word or keyword for meaningful names in the language? Aliasing

6 Location

7 Location Static Stack dynamic Explicit heap dynamic
Implicit heap dynamic rare, used in APL and Algol-68

8 Type

9 Type Primitive or complex Usually bound statically Coercion or casting
but can be dynamic in LISP, APL, SNOBOL Coercion or casting Strong typing language “always detects type errors” Name compatibility or structure compatibility name: same declaration or same type name easier to implement but restrictive structure: same internal structure may not be strict enough

10 Type (continued) Most languages use a combination of equivalence methods Pascal: usually structure, but in some cases name is used (formal parameters) C: structure, except for records C++: name Ada: restricted form of name derived types allow types with the same structure to be different type celcius is new real; type fahrenheit is new real; subtype allows types to be compatible even with different names subtype digit is INTEGER range 0..9;

11 Scope

12 Scope Range of statements in a program when a name can be referenced (is visible) Controlled by subprograms, compound statements Static most languages Dynamic APL, SNOBOL, some LISPs means no compile-time type checking of non-local objects

13 Lifetime

14 Period when data object is allocated memory
Can be different than scope hole in scope static variables invoking external subprogram


Download ppt "Types and Related Issues"

Similar presentations


Ads by Google