(Data) Type - (Datatype|Type of data)

1 - About

Variables, parameters, and function may be typed (static typing) and return values that are typed (as do a database column).

The type of a variable or expression defines the characteristics of the values it may take on, such as:

  • their size (number of bits or number of elements),
  • how they are represented internally,
  • the intrinsic operations that can be performed on them,
  • and the methods associated with them.

In any program there are variables that share the same representation but signify very different concepts.

For instance,

  • An int could be used to represent:
    • a loop index,
    • a timestamp,
    • a file descriptor,
    • or a month;
  • A float64 could represent:
    • a velocity in meters per second
    • or a temperature in one of several scales;
  • and a string could represent:
    • a password
    • or the name of a color.

A type restricts the possible values to which:

at run time or compile time

High-level languages are characterized by the fact that objects of programs, for example variables and functions, are classified according to their type.

Data type define the class of data that can be stored in a variable.

It defines what sort of information (data structure) is (or not) accepted as input into a column or or a field.

Each value manipulated as a datatype:

  • in an application (such as a database)
  • or in a development language.

The datatype of a value associates a fixed set of properties with the value. These properties cause the software to treat values of one datatype differently from values of another. For example, you can add values of NUMBER datatype, but not values of RAW datatype.

A type gives hints on the set of operations that the data type will support.

See also:

  • Type_system: a type system is a collection of rules that assign a data type to various constructs composing a computer program, such as variables, expressions, functions or modules. Typing is concerned with assigning a type to any object.
  • Data Type - Duck typing determines the suitability of an object by the presence of methods and properties, rather than the actual type of the object as in typing.

For the SQL specification, a data type is a set of representable values. Every data value belongs to some data type. Every data type is either predefined, constructed, or user-defined. Every data type includes a special value, called the null value.

Types enable developers to use highly-productive development tools and practices like:

Type inference allows a few type annotations to make a big difference to the static verification of your code.

Types let you define interfaces between software components and gain insights into the behavior of existing libraries.

3 - Named Type

A type declaration defines a new named type that has the same underlying type as an existing type.

4 - Controle the Domain of values

These datatypes define the domain of values that each column can contain or each argument can have. For example, DATE columns cannot accept the value February 29 (except for a leap year) or the values 2 or 'SHOE'.

Each value subsequently placed in a column assumes the datatype of the column. For example, if you insert '01-JAN-98' into a DATE column, then database treats the '01-JAN-98' character string as a DATE value after verifying that it translates to a valid date.

5 - Variable Actions defined their type

When you need to:

6 - Type

First:

After the primitive data type, one of the most common data structures in software development are the (aggregate|compounds) types:

Then:

  • Composite: that is, types built up from simpler ones

Type may be:

  • abstract (tables, tree…) as they may be implemented on different ways.
  • vs concrete types (ie all other type).

Other:

7 - Documentation / Reference

code/type/type.txt · Last modified: 2017/09/17 17:36 by gerardnico