Andreas Rossberg wrote: > AFAICT, ADT describes a type whose values can only be accessed by a > certain fixed set of operations.
No. AFAIU, an ADT defines the type based on the operations. The stack holding the integers 1 and 2 is the value (push(2, push(1, empty()))). There's no "internal" representation. The values and operations are defined by preconditions and postconditions. Both a stack and a queue could be written in most languages as "values that can only be accessed by a fixed set of operations" having the same possible internal representations and the same function signatures. They're far from the same type, because they're not abstract. The part you can't see from outside the implementation is exactly the part that defines how it works. Granted, it's a common mistake to write that some piece of C++ code implements a stack ADT. For example, an actual ADT for a stack (and a set) is shown on http://www.cs.unc.edu/~stotts/danish/web/userman/umadt.html Note that the "axia" for the stack type completely define its operation and semantics. There is no other "implementation" involved. And in LOTOS (which uses ACT.1 or ACT.ONE (I forget which)) as its type, this is actually how you'd write the code for a stack, and then the compiler would crunch a while to figure out a corresponding implementation. I suspect "ADT" is by now so corrupted that it's useful to use a different term, such as "algebraic type" or some such. > Classes qualify for that, as long as they provide proper encapsulation. Nope. > OK, I admit that I exaggerated slightly. Although currently I'm indeed > able to mostly work with the more pleasant among languages. :-) Yah. :-) > (Btw, Pascal did not have it either, AFAIK) I'm pretty sure in Pascal you could say Type Apple = Integer; Orange = Integer; and then vars of type apple and orange were not interchangable. -- Darren New / San Diego, CA, USA (PST) My Bath Fu is strong, as I have studied under the Showerin' Monks. -- http://mail.python.org/mailman/listinfo/python-list