 |
<Types> |
[
Basic Types |
Composite Types |
Type Modifiers |
Initial Values |
Conversion |
Coercion
]
[
void |
bool |
int |
float |
char |
string |
time |
file |
html |
tuple |
relation |
vector
]
- void
- The type void is special and purely used in
association with the declaration of functions not returning anything
(a.k.a. procedures). It is not possible to create a variable of type
void.
- bool
- There are only two possible values of type bool
(a.k.a. boolean), namely "true" and
"false". The type would thus ideally occupy
one bit at runtime. However, for reasons of efficiency it is
represented internally by an int.
- int
- The integer type, int, is for signed numbers. It
corresponds directly to C's int which means that its precision is
implementation specific. The size will typically reflect the natural
word size of the host machine, the size is typically 32 (or 64) bits,
although it is guaranteed to be at least 16 bits.
- float
- The float type is for signed pseudo real
numbers. They correspond to C's double the precision
of which is implementation specific. They will typically be 64 (or
128) bits.
- char
- The values of type char are (ascii) characters
that occupy 8 bits at runtime.
- string
- A string is a basic type, the values of which are
arbitrary sequences of chars starting from zero. All
strings are at runtime represented as indices into a
local string-pool holding the actual string
along with its length. Thus, operations such as string-compare
"s==t" and string-length "|s|"
takes constant (not linear!) time. The lexicographic order operators
"<" and ">" take time linear in the size of the strings compared.
- time
- The values of type time are legal points in
time. That is, a (gregorian calender) date and an hour-minute-second
time of day. Illegal times, such as "1999/02/29, 20:61:30"
are automatically converted to legal ones ("1999/03/01,
21:01:30"). The predefined function now() returns the current time. All
time values must be within the following range [1970/01/01,
00:00:00..2038/01/19, 03:14:07]. Any attempts to construct a
time not in this interval will result in the special
time value called notime
which is also the default value for the type time. See Time for more information.
- file
- The values of type file are file-handles
with a limited number of operations. See Files
for more information.
- html
- html is a special type in
<bigwig>
. A value of type html is an html document with
a number of named gaps that can be plugged with strings or other html
documents at runtime. The html documents are represented in a very
compressed format with maximum sharing and where the plug operation
takes constant time. See Dynamic Documents
for more information.
- tuple
- The tuple type is defined relative to a schema
which is essentially a mapping from identifiers to basic types. A tuple
value is thus a mapping from identifiers to basic values corresponding
to the names and types of the associated schema. The tuple identifiers
are commonly referred to as attributes. See Database for more information.
- relation
- A relation is a set of tuples with no notion of order and where no
value is present twice (any redundant values are implicitly removed).
The factor operation is available
for traversing relations. See Database for more information.
- vector
- There are two kinds of Vectors (a.k.a. lists or arrays) in
<bigwig>; basic vectors and tuple
vectors. Basic vectors are capable of storing lists of basic values,
while tuple vectors contain lists of tuples. Both kinds can be
multi-dimensional. See Database for
more information.
- const
- Any type can be prefixed with the type modifier
const. Variables of type const can only be assigned values by the initialization expression at the point of declaration.
- shared
- This modifier can be applied to all variable declarations, making the variables persistent and shared among all session threads of the service.
<bigwig> initializes all variables upon
declaration, hence all types have associated initial values. These
values can be seen in the table below. The precision of all types are
inherited by that of the compilation target language (C).
| Type |
Min. prec. |
Typ. prec. |
Initial Value |
Order |
Equality |
| void |
N/A |
N/A |
N/A |
N/A |
N/A |
| bool |
1 bit |
1 bit |
false |
N/A |
yes |
| int |
16 bits |
32 bits |
0 |
numeric |
yes |
| float |
32 bits |
64 bits |
0.0 |
numeric |
yes |
| char |
8 bits |
8 bits |
' ' (space) |
ascii |
yes |
| string |
N/A |
N/A |
"" |
lexicographic |
yes |
| time |
32 bits |
32 bits |
notime |
numeric |
yes |
| file |
N/A |
N/A |
N/A |
N/A |
no |
| html |
N/A |
N/A |
<html></html> |
N/A |
no |
| tuple |
N/A |
N/A |
tuple { ... * } |
N/A |
yes |
| relation |
N/A |
N/A |
relation { } |
N/A |
no |
| vector |
N/A |
N/A |
vector { } |
N/A |
no |
*) The individual attributes in the tuple will have initial values
dictated by their types. The types of attributes in a tuple are all
required to be basic.
<bigwig> provides a simple means for explicit
conversion. The legal conversions and their semantics are listed
below. All types (except file) can be converted to and
from string. Conversion is specified by prefixing a
given expression with the name of the type in parentheses (as in a
C or Java type cast).
- bool can be converted to:
- string: true and false become "true" and "false", respectively.
- html: true and false become <html>true</html> and <html>false</html>, respectively.
- int can be converted to:
- float: Straightforward. For instance, 42 becomes 42.0.
- char: Integers are converted to chars according to their ascii value (modulo 256). For instance, 65 becomes 'A'.
- string: Straightforward. For instance, 42 becomes "42".
- html: Straightforward. For instance, 42 becomes <html>42</html>.
- float can be converted to:
- int: Floating point numbers are truncated to integers. For instance, 1.75 becomes 1.
- string: Straightforward. For instance, 3.14 becomes "3.14".
- html: Straightforward. For instance, 3.14 becomes <html>3.14</html>.
- char can be converted to:
- int: Chars are converted to ints according to their ascii value. For instance, 'A' becomes 65.
- string: All chars are converted to a strings of length one. For instance, 'x' becomes "x".
- html: Straightforward. For instance, 'x' becomes <html>x</html>.
- string can be converted to:
- bool: "false" becomes false, the rest becomes true.
- int: Strings only containing digits (and white-spaces) are translated directly into integers. All other strings become 0. For instance, " 42" becomes 42
- float: As above, except that the string may contain one dot. For instance "3 . 14" becomes 3.14.
- char: Empty strings become '\0', the rest become the first character in the string. For instance, "hello" becomes 'h'.
- time: Currently Strings must be "yyyy/mm/dd, hh:mm:ss".
- html: Strings are translated into html by
escaping angled brackets. For instance, the string "<bigwig>" is turned into "<html><bigwig></html>". Alternatively, if the brackets should not be escaped, the type conversion construct rawhtml may be used (with caution!).
- tuple: The string will be unserialized.
- relation: The string will be unserialized.
- vector: The string will be unserialized.
- time can be converted to:
- string: Returns "yyyy/mm/dd, hh:mm:ss" (using a 24 hour representation).
- html: Straightforward. First it is converted to a string then the string is converted to html.
- tuple can be converted to:
- string: The tuple will be serialized.
- html: Straightforward. First it is converted to a string then the string is converted to html.
- relation can be converted to:
- string: The relation will be serialized.
- html: Straightforward. First it is converted to a string then the string is converted to html.
- vector: Straightforward. The order of the individual tuples is unspecified.
- vector can be converted to:
- string: The vector will be serialized.
- html: The vector will be serialized.
- relation: Straightforward. Redundant entries are removed.
<bigwig> generally does not coerce
expressions. The exceptions to this rule are plug, receive, and string
concatenation. Any basic value can be plugged into a document gap,
causing a coercion from this type to the html type as explained under
conversion above. Similarly, at
receive the assigned variable can have any basic type
(wherever a basic type is expected, see Form Input
Table). As for string concatenation '+', if one of the
arguments is of type string, the other is automatically coerced to a
string prior to concatenation.