Names Variables Type Checking Strong Typing Type Compatibility
Names Variables Type Checking Strong Typing Type Compatibility
Variables
Type Checking
Strong Typing
Type Compatibility
Names
A
Names (continued)
Length
FORTRAN I: maximum 6
COBOL: maximum 30
FORTRAN 90 and ANSI C: maximum 31
Ada and Java: no limit, and all are significant
C++: no limit, but implementers often
impose one
4
Names (continued)
Connectors
Names (continued)
Case
sensitivity
Special Words
A keyword is a word that is special
only in certain contexts
e.g., in Fortran
Real VarName
Real = 3.4
(Real is a variable)
Variables
A
variable is an abstraction of a
memory cell
Variables can be characterized by
the following attributes:
Name
Address
Value
Type
Lifetime
Scope
8
Variables Attributes
Name
Variables Attributes
(continued)
Type
memory cell
Type Checking
Generalize
If
12
Strong Typing
Language examples:
FORTRAN 77 is not : EQUIVALENCE
Pascal is not: variant records
C and C++ are not: In functions parameter type checking
can be avoided; unions are not type checked
Ada is, almost (UNCHECKED CONVERSION is loophole)
(Java is similar)
13
Strong Typing
Coercion
Although
Type Compatibility
Name
Type Compatibility
Structure
Type Compatibility
15
16
Structure Type
Compatibility
Structure
type compatibility
means that two variables have
compatible types if their types
have identical structures
More flexible, but harder to
implement
17