vieweditattachhistoryswikistopchangessearchhelp

抽象データ型とオブジェクト指向の決定的な違い

その後の学習でこの問題は解決しています。現在主流の型を意識したオブジェクト指向は、(SIMULA 67 由来の)クラスという言語機能を使って抽象データ型(簡単に言うとユーザー定義型)を実現しようとする手法なので「抽象データ型のオブジェクト指向」とも呼ばれています。つまり、狭義あるいは実装手法のひとつとしての抽象データ型(型に手続きを含めない)を別にすれば、概念としての抽象データ型といわゆる「オブジェクト指向」には違いはありません。あしからず。以下は学習過程の記録として残しますが、あくまで参考としてお読みください。--sumim






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.




はやい話、両者に決定的な違いはなさそう。SIMULA 67 が具現化したものをどう解釈・運用するかでオブジェクト指向抽象データ型かに分かれるのでは? ただ、Simula67 はオブジェクト指向をうたっていたので、違う立場の人間による別解釈が抽象データ型だといえるのかも。--sumim



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.

ADT, abstract data types; PDA, procedural data abstraction, i.e. object oriented.

Implementation of lists as abstract data types

adt 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-oriented

Nil = 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
--sumim

このページを編集 (3103 bytes)


Congratulations! 以下の 1 ページから参照されています。

This page has been visited 5455 times.