The development of abstract data types and object-oriented programming, from their roots in Simula 67 to their current diverse forms, has been prominent in programming language research for the last two decades.
The client has an abstract view of data in both ADTs and PDA. The major difference between them is the technique used to enforce the encapsulation and abstraction. In an ADT the mechanism is type abstraction, while in PDA it is procedural abstraction. Another major difference is that in PDA the objects act as clients among themselves, and so are encapsulated from each other. In an ADT, the abstract values are all enclosed within a single abstraction, and so they are not encapsulated from each other.--sumim
ADT, abstract data types; PDA, procedural data abstraction, i.e. object oriented.
Implementation of lists as abstract data typesadt IntList representation list = NIL | CELL of integer * list operations nil = NIL adjoin(x : integer, l : list) = CELL(x, l) null?(l : list) = case l of NIL ==> true CELL(x, l) ==> false head(l : list) = case l of NIL ==> error CELL(x, l 0) ==> x tail(l : list) = case l of NIL ==> error CELL(x, l 0) ==> l 0 equal(l : list, m : list) = case l of NIL ==> null?(m) CELL(x, l 0) ==> not null?(m) and x = head(m) and equal(l 0, tail(m))
Implementation of lists as object-orientedNil = recursive self = record null? = true head = error; tail = error; cons = fun(y) Cell(y, self); equal = fun(m) m.null? end Cell(x, l) = recursive self = record null? = false head = x; tail = l; cons = fun(y) Cell(y, self); equal = fun(m) (not m.null?) and (x = m.head) and l.equal(m.tail) end
このページを編集 (3103 bytes)
|以下の 1 ページから参照されています。|
This page has been visited 4743 times.