<Types>

[ Basic Types | Composite Types | Type Modifiers | Initial Values | Conversion | Coercion ]


[ void | bool | int | float | char | string | time | file | html | tuple | relation | vector ]

Basic Types

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.


Composite Types

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.


Type Modifiers

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.


Initial Values

<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.


Type Conversion

<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).


Coercion

<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.


bigwig@brics.dk
Last updated: November 2, 2001
Valid HTML 4.01!