Re: value type pardox
Nilone <reaanb@gmail.com> writes:
A type is a named set of values, and a value is a member of
such a set.
There are additional properties of types in computer
science. For example, when we ignore subtypes for a moment,
we can say that every value v belongs to exactly one type.
Your definition would allow a value to belong to several
types, as a value can be a member of several, overlapping
sets.
Also, you give no definition for ?value?. So, what is a
value? To explain this, many authors also require more
structure in a type than just the set structure and deem
certain operations and other structures to be a part of the
type.
Types have operators
Now you write it yourself. But when you define a type as a
?set? it does not have operators, because a set is solely
determined by its members and has no operators.
Classes and objects are somewhat more complex.
A common description of both primitive types and
non-primitive types possibly can be given, when one sees a
type as a set of certain operations.
An interface is a type
Yes, this comes close to the idea of a type as a set of
operations. The values then possibly can be derived from
requirements on those operations. (Somewhat as in category
theory.)
That is, we begin with an
http://en.wikipedia.org/wiki/Abstract_data_type
and then we conclude the properties its values need so
as to fulfill the constrains of the ADT.
This can also be applied to primitive types, where the
operations of the type are the usual operators, like +, -,
*, /, <, >, ==, and so on for the type int.