Difference between revisions of "Kepsec"
m |
m |
||
Line 33: | Line 33: | ||
A variable of union type may be either a value or reference type depending on the type the variable is currently representing. | A variable of union type may be either a value or reference type depending on the type the variable is currently representing. | ||
+ | |||
+ | One union type is predefined, and is called the '''any''' type. The '''any''' type can reference any type, including itself. |
Revision as of 03:39, 12 March 2010
wip straw-man kepsec proposal. types and expressions may apply, see store for details.
Contents
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.
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. A variable of a union type can represent an instance of any type allowed by the union type. However, exactly one type may be represented in a given variable.
A variable of union type may be either a value or reference type depending on the type the variable is currently representing.
One union type is predefined, and is called the any type. The any type can reference any type, including itself.