[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Assignments] [Labs]
Back to Data Types (II). On to Object-Oriented Programming.
Held Wednesday, April 21
Summary
Contents
Notes
eqv? in Scheme requires
some careful consideration of when functions or pairs are equivalent.
type xy = record
x: integer;
y: real;
end;
xy_alias = xy;
ab = record
a: integer;
b: real;
end;
yx = record
y: real;
x: integer;
end;
abc = record
a: integer;
b: real;
c: real;
end;
intrec = record
x: integer;
end;
iarr = array[1..10] of integer;
iare = array[2..11] of integer;
var
rec1: xy;
rec2: xy_alias;
rec3: ab;
rec4: abc;
rec5,rec6: record a: integer; b: real; end;
rec7: record a: integer; b: real; end;
rec8: yx;
rec9: intrec;
rec10: xy;
arr1: iarr;
arr2: iare;
arr3,arr4: array[1..10] of integer;
arr5: array[1..10] of integer;
rec1 and rec3 are structurally equivalent as
they are both pairs of (integer,real).
rec1 and rec8 are not structurally equivalent,
as they order their elements differently.
rec1 and rec3 are not structurally
equivalent under naming as they name their pairs differently.
rec3 and rec6 are structurally equivalent
under naming.
rec1 and rec2 are not name equivalent.
rec1 and rec10 are name equivalent.
type
alpha = record
i1: integer;
i2: integer;
end;
aardvark = record
i1: integer;
i2: integer;
beta = record
i: integer;
a: alpha;
end;
bandicoot = record
i: integer;
a: aardvark;
end;
alpha and aardvark are clearly equivalent.
Are beta and bandicoot? How do you tell?
type
listp = pointer to list;
list = record
i: integer;
next: listp;
end;
lstp = pointer to lst;
lst = record
i: integer;
next: lstp;
end;
type
gammap = pointer to gamma;
deltap = pointer to delta;
gamma = record
i: integer;
next: deltap;
end;
delta = record
i: integer;
next: gammap;
end;
3 + "4" in languages that can convert strings to integers.
ab and abc above.
History
Back to Data Types (II). On to Object-Oriented Programming.
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Assignments] [Labs]
Disclaimer Often, these pages were created ``on the fly'' with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS302/99S/Outlines/outline.32.html
Source text last modified Wed Apr 21 09:27:44 1999.
This page generated on Wed Apr 21 09:35:55 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at rebelsky@math.grin.edu