








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









ˇ There are two categories o Syntactic o Semantic
ˇ Static: o During compilation o It is preferred.
ˇ Statically Typed Languages are Strongly Typed Languages.
ˇ Structure type compatibility : o Two variables have compatible types if their types have identical structures. o It is more flexible. o It is difficult to implement: compare the whole structure instead of just names. o Two types are structurally compatible if:
o Examples:
#include <stdio.h>
main(){
char c1 = 'a'; int i = 10;
SUBTYPE Day_Range IS Integer RANGE 0..31; SUBTYPE Year_Range IS Integer RANGE 1901..2099; SUBTYPE natural IS integer range 0..integer'last;
SUBTYPE natural IS integer RANGE 0..integer’last; SUBTYPE positive IS integer RANGE 1..integer’last;
ˇ Bind generic types to concrete types at compile- time instantiation.
push: stack(T)xT → stack(T) pop: stack(T) → stack(T)xT length: stack(T) → int
ˇ Type equivalence ˇ Coercion ˇ Subtyping ˇ Overloading
polymorphism
Parametric (Templates)
Inclusion (subtypes)
overloading
coercion
universal
Ad hoc
ˇ Descriptor: structures used to store the attributes of the data ˇ Data object: memory locations to store the actual values
ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ
Descriptor
integer
sign bit
Descriptor
real
sign bit for mantissa sign bit for exponent
k-bit exponent h-bit mantissa
another_type struct a float
b int
type x_type = array[0..10] of real; type z_type = record case kind: boolean of true: (a:integer); false: (b:x_type); end;
Type Z_type constructor Variant record Selector Kind Type Boolean Case table Boolean value Reference Case table True false Selector b Type X_type Constructor array Selector a Index type Integer Type L. bound 0 reference integer U. bound 10 Range type real Reference
S = {1, 3, 10, 16}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 10 0 0 0