Kepsec

From AlliedModders Wiki
Jump to: navigation, search

wip straw-man kepsec proposal. types and expressions may apply, see store for details.

Types

KE types are categorized as either value or reference types. Variables of a value type contain their data directly, whereas reference types contain a reference to their data. This means with a reference type, multiple variables can lead to the same underlying data. With value types, each value has its own copy, and thus cannot affect another variable.

Bool

The bool type is a value type, and represents two values: true and false.

String

The string" type is a value type, and represents ordered, finite sequences of textual characters. The length of a string is its number of elements. The size of each element is fixed, but unspecified. A string can contain zero or more elements. The maximum size of a string is unspecified, but must be at least 65,535 characters.

Integer

The int type is a value type, and represents any integer in ℤ. Integers have infinite, arbitrary precision. An implementation may limit the precision of integers if and only if it does not violate their operational semantics as described in this document.

NOTE: For example, a resource-constrained implementation may choose to trigger "out of memory" errors if an integer cannot be expressed in a 32-bit, signed machine register. However, it cannot violate the semantics of integer operations, such as overflow.

Double

The double type is a value type, and represents any value in the IEEE-754 double-precision, 64-bit floating point standard, with one exception: the 2^53-2 "NaN" values are represented by a single NaN value.

Three special values are also defined:

  • Positive Infinity, referred to symbolically in this document as ∞.
  • Negative Infinity, referred to symbolically in this document as -∞.
  • Negative Zero. Unless specified otherwise, as in the language, 0 is a positive zero, and -0 is a negative zero.

Array

An array is a reference type that collects zero or more values of exactly one type in an ordered, finite sequence. The maximum number of values in an array is unspecified for implementations, but must be at least 268,435,455, or (2^28 - 1).

Union

Unions are a special class of user-defined types that proxy another type. The set of types which a union can proxy is determined by the union definition, and union types cannot proxy themselves. Unions are value types, and at any given time, contain data for exactly one of its proxied types.