A definition of data type I've seen is along the lines of "a set of values and a set of operations".

What exactly does an operation in this set comprise?

For instance, might an operation be considered as:

  • an identifier (e.g. integers have an operation, +)

  • an identifier with signature (e.g. + operates on two integers and results in an integer)

  • an identifier with signature and established behaviour (e.g. 1 + 2 = 3)

  • an identifier with signature and behaviour, together with some underlying implementation

or some other concept?


It sounds like you might be asking about an abstract data type. If so, the answer is the third option: "an identifier with signature and established behaviour".

If you are asking about a data type, then I'm not sure there's a clear answer that applies to all type systems and all programming languages. Syntactically, I think it falls closest to your second option: "an identifier with signature" -- the type checker doesn't know anything about the intended behavior. However, in practice programmers might associate other things with a type: for instance, the type might indicate the intended meaning of the data, it might indicate the intended behavior of the operations, it might indicate how the data is represented or stored, and it might even encode other distinctions -- though many of these might not be checked by the compiler's type checking or might not be visible to the compiler.

| cite | improve this answer | |
  • $\begingroup$ Yes, thinking of data type as opposed to ADT, but useful to have the distinction. $\endgroup$ – Steven Maude Jan 20 '17 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.