# Annotated King Reference Manual/Types

This page is work in progress.

## Type Declarations

Some general principles:
* All scalar subtypes have a default value. For bounded numeric and enumeration subtypes, this is the 'First of the subtype, unless a different value is specified with the Default_Value aspect. For unbounded numeric subtypes, the Default_Value aspect must be specified. Note that an unbounded numeric type can have bounded subtypes.
* The Predicate aspect may be specified for all subtypes.
* All scalar types have the attributes 'Image, 'Value, 'Min, 'Max, 'Previous, and 'Next.
* Integer and enumeration types have the attributes 'Position, 'Value (integer), 'Representation, and 'From_Representation. For integer types, 'Position and 'Representation both give the value of the parameter, and 'Value (integer) and 'From_Representation give the value of the type with the value of the parameter (if that exists); this is similar to 'Pos and "Val for integer types in Ada.
* 'Image <=>, 'Value (string) are inverses of each other, as are 'Position <=> 'Value (integer)

### Discussion
## Enumeration Types
### Attributes

First, Last, Position, From_Representation, Representation, Image, Value, Min, Max, Previous, Next

### Aspects

Bit_Size, Byte_Size

### Discussion
## Integer Types
### Operators

+ - * / rem mod ^ = /= < <= > >= and or xor not

### Attributes

First, Last, Bit_Wise_Operators, Image, Value, Min, Max, Previous, Next, Valid
Additional attributes with Bit_Wise_Operators = True:
Shift_Left, Shift_Right, Rotate_Left, Rotate_Right, Mod

### Aspects

Default_Value, Predicate, Signed_Representation, Overflow_Checking

### Rationale

Bit-wise operations are available for the base type of all bounded integer types that fit in a single hardware integer.

### Discussion
## Real Types
### Floating Point Types
#### Examples
##### Unbounded floating-Point Types
#### Syntax
#### Attributes

Image, Value, Min, Max, Previous, Next, Valid, digits

#### Aspects

Default_Value, Predicate

#### Discussion
### Fixed Point Types
#### Attributes

Image, Value, Min, Max, Previous, Next, Valid, delta

#### Aspects

Default_Value, Predicate

#### Rationale

Shouldn't decimal types be available, in order to cover the corresponding available type of Ada?
A King fixed-point type with a delta that is a power of 10 is equivalent to an Ada decimal fixed-point type.
type Money is delta 0.01 digits 14;
The above would be equivalent to:
type Money is delta 0.01 range -999_999_999_999.99 .. 999_999_999_999.99;

#### Discussion
## Map Types
### Operators

"=" is only defined if it is defined for the value subtype.

### Operations

Delete, Clear, Defined, Size

### Rationale

Maps may also be implemented by functions, so King uses a common notation for both.

### Discussion
## Sequence Types
### Operators

"=" is only defined if it is defined for the value subtype.

### Operations

Delete, Clear, Length

### Discussion
## Set Types
### Operators

+ - * / = /= < <= > >= [not] in

### Operations

Size

### Discussion
## Record Types
### Discussion
## Derived Types
### Rationale

The operations, attributes, and so on are based on the parent type.

### Discussion
## Passive Task Types
### Examples
### Rationale

Passive tasks are the only way that active tasks may communicate.