Data Types
Data types supported by Warp.
Numerical Types
int<N>- An N-bit integer (where 1<=N<=64)
int- The 'natural' integer value for the platform, either 32 or 64 bits
short- An alias for
int<16> long- An alias for
int<64> bits<N>- An unsigned integer (where 1<=N<=64)
bits- An unsigned integer with the same number of bits as an
int(either 32 or 64) bit- An alias for
bits<1> byte- An alias for
bits<8> char- Equivalent to
bits, except that it cannot be used as a boolean value address- An integer with the same size and signedness as a memory address; may not be used as a boolean value
fixed<N>- An arbitrarily large, signed, fixed-point decimal number with N digits to the right of the decimal point; e.g.,
fixed<2>could be used to represent a decimalized currency like US Dollars or Euros fixed- An alias for
fixed<2> bigint- An arbitrarily large integer, an alias for
fixed<0> float- An IEEE-754 32-bit single-precision floating point number
double- An IEEE-754 64-bit double-precision floating point number
bignum- The largest supported floating-point number: an IEEE-754 79-bit floating point number if supported; 64-bit otherwise
Aggregate Types
struct- A collection of named fields, possibly of different types; fields may be word-aligned within the struct for efficiency
mask- A collection of named
int<N>andbits<N>fields, packed within a space of 64 bits or less; declaration and usage syntax is the same asstruct array<T>- An ordered, integer-indexed, fixed-length list of changeable values of type T
stack<T>- An ordered, integer-indexed list of changeable values of type T that allows items to be added to and removed from one end
table<K,V>- An associative array containing keys of type K and values of type V
Other Types
string- Opaque, immutable sequence of Unicode characters
pattern- Perl6-style 'regular expression'
proc- A callable procedure
ref<T>
- A pointer to a memory location containing a value of type T
overlay- A collection of named entities of various types, that occupy the same space in memory (equivalent to a C
union); declaration and usage syntax identical to struct void
- A placeholder for an unspecified type
There is no distinct boolean type; use bit, or any integer type (except address or char) instead. Treating any other type as a boolean is a syntax error.
In a boolean context, the truth value of int and bits types are based on their least significant bit: true if odd (LSB set), false if even (LSB clear). (Note that since a single bit is used to determine the truth value, there is no need to distinguish between bitwise and logical and/or/xor/not operators.)
The implementation of string is opaque; it may be internally implemented as an array of chars, bytes (UTF-8), bits<16>s (UTF-16), or something else entirely, depending on what is most efficient for the platform and locale; it is even permissible to mix implementations, using whatever representation is most efficient for a particular string.
A string's contents are immutable, though string variables are a reference type, so they can be assigned new values. (See Python for an example of this.) If you want to change a string, create a new one. Strings created at run-time are allocated on the heap, and garbage-collected by a simple reference-counting mechanism. (Cyclical dependencies are not a problem here, since strings cannot reference other strings.)
All of the indexed list types (array, stack, and string) are indexed using integers, with 0 as the first element. They may also be accessed using negative integers to count down from the end, with -1 as the index of the last element. Any bit within a bits<> type may also be accessed using array index notation, with bitVar[0] as the least significant bit.
Slicing of indexed list types is supported, using the notation listVar[M,N], which yields all elements starting with (and including) array[M], up to (but not including) array[N]; this notation, too, applies to bits<> values. You may assign to a slice of a stack, and the array value assigned need not be the same size as the slice; you may not do this with arrays, strings, or bits types.
Any procedure expecting a read-only array as an argument will accept a stack as well; the reverse is not true. Any procedure expecting a read-only array or stack of char values will accept a string; and the reverse is true.
