Glich - v0.3.0 Manual
Script Value Types
Home Development v0.3.0 Manual Glich Script Value Types

Value Types

Glich supports the following value types.

String

A string is sequence of unicode (UTF-8) characters. It is written by enclosing the text in double quotes '"'. If a double quote is required in the text, use two double quotes together. For example, the value "Say ""Hello""" would print as Say "Hello".

Float

A floating point number.

A float may hold the following special values.

KeywordMeaning
infInfinity. Can be preceded by a plus '+' or minus '-' sign.
nanNot a number.

Any operation with nan results in nan, with the exception of equal = and not equal <>.

float_type is also part of the numeric_type and any_numeric_type groups.

Number

A number is a 64 bit signed integer value.

number_type is also part of the integer_type, numeric_type and any_numeric_type groups.

Field

A field is a 32 bit signed integer value with some fixed values. It is used to form integer ranges and sets. It can be used with the set operands: complement '!', union '|', intersection '&', symmetric difference '^' and relative compliment '\'.

A field may hold the following special values.

KeywordMeaning
infiniteCan be preceded by a plus '+' or minus '-' sign.
?An unknown or indeterminate value.

field_type is also part of the set_type, integer_type, numeric_type and any_numeric_type groups.

Range

A range is expressed as two field values which denote the first and last values of an inclusive, continuous list. Both values may be the same, which implies a list of one value. A range is written using the '..' operator. Note, (a..b) is identical to (b..a). When a range is output as a string it is always written with the lower value first.

The infinity value is permitted in a range but not the '?' value.

A field may be promoted to a range with the upper and lower values equal.

A range may only be demoted to a field if both values are equal.

range_type is also part of the set_type, combined_type and any_numeric_type groups.

Rlist

An rlist is a list of ranges. The list may contain zero or more ranges. If the rlist has more than one range, it is written using the union '|' operator between ranges. When an rlist is output, it is always written as a well ordered list.

A well ordered list can be described as when, ranges are always shown with the lowest value first, multiple ranges do not overlap or abut one another and are in ascending order.

The rlist may hold the special value keyword 'empty', meaning it is the empty or null set.

A range may be promoted to an rlist with a single range.

An rlist may only be demoted to a range if, after conversion to a well ordered list, it contains a single range.

rlist_type is also part of the set_type, combined_type and any_numeric_type groups.

Boolean

A boolean value holds one of the two keywords 'true' or 'false'.

Object

An object value holds a collection of other values. It has to be defined and given a code first. After its definition it can written by enclosing the values in curly brackets, starting with the objects code name.

The language contains one built-in general purpose object that does not need to be defined before use. This is documented here.

Blob

Can be used for binary data, as listed below.

Blob TypeDescription
unknownUnknown binary data
fileRepresents any binary file
jpeg, pngImage data.
mp3Audio data.
mp4Video data.

Currently, this type can only be used with the function @load:blob and command save:blob.

When a string description of a blob is required, it is given in the form blob:type:size. For example blob:png:1999.

Error

An error value is created whenever an operation is carried which has undefined results. When written out, the value should print text that describes where and why the error was created.

Null

A null value holds the keyword 'null'.

Only the equal '=' and not equal '<>' operators may be used with null values. The equals operator returns 'true' if both values are null and 'false' otherwise. Any other operation with null is undefined and results in an error value.

Null values can be used as place-holder values within an object value.

Summary of Types

stringstring_type
floatfloat_typenumeric_typeany_numeric_type
numbernumber_typeinteger_type
fieldfield_typeset_type
rangerange_typecombined_type
rlistrlist_type
booleanbool_type
objectobject_typenamed_object_type
blobblob_type
errorerror_type
nullnull_type

Automatic Type Conversions

When an operation expects two numeric types then, if both types are the same, this will be the type of the output. If the types differ, one of the types will attempt to be converted as follows.

If either type is a float, the other type will be converted to a float.

If the types are a number and a field, in either order, the number is converted to a field if possible. If the conversion would causes an overflow, it is converted to the unknown ? value.

Set types are automatically promoted or demoted as required to suit the operation. If a demotion is required but not possible then an error type is returned. Promotions are always possible.

Any other operation with unmatched types will return an error type.

Home Development v0.3.0 Manual Glich Script Value Types

Managed by WebPageLayout Validated by HTML Validator (based on Tidy)

22nd September 2024