We begin with an overview of the types of values supported by
Bro,
giving a brief description of each type and
introducing the notions of type conversion and type inference.
We discuss each type in detail in § -§
below.
There are 18 types of values in the Bro type system:
Every value in a Bro script has one of these types.
For most types there are ways of specifying constants representing
values of the type. For example, 2.71828 is a constant
of type double, and 80/tcp is a constant of type
port. The discussion of types in
§ -§
below includes a description
of how to specify constants for the types.
Finally, even though Bro variables have static types, meaning that their type is fixed, often their type is inferred from the value to which they are initially assigned when the variable is declared. For example,
local a = "hi there";fixes a's type as string, and
local b = 6;sets b's type to count. See §
Some types will be automatically converted to other types as needed. For example, a count value can always be used where a double value is expected. The following:
local a = 5; local b = a * .2;creates a local variable a of type count and assigns the double value 1.0 to b, which will also be of type double. Automatic conversions are limited to converting between numeric types. The rules for how types are converted are given below.