Literals

— defined for integers, reals, strings, and symbols.

Integers

An integer is any group of digits defining a number between -2e+31 and 2e+31 - 1. It cannot contain a decimal point or an exponent. Integers have several different literal notations, but regardless of notation, all integers are 32 bit signed numbers. They are flagged internally with their respective notations and Gamma attempts to maintain and return the notation when the integer is printed.

Table 4. Integers
NotationDescriptionExample
 Decimal notation539
0bBinary notation0b1011
0oOctal notation0o462
0xHexadecimal notation0x35fc
' 'Contents are a character.'M'

Real numbers

A real number is any group of digits defining a number less than -2e+31, greater than 2e+31 - 1, or containing a non-zero mantissa. It can contain a decimal point, and it may end with the letter e followed by a signed exponent.

Table 5. Real numbers
NotationDescriptionExample
[0-9].[0-9]e[+|-][0-9]Double-precision 64 bit floating-point number.2.56e-7

There are four pre-defined constants in Gamma:

PIThe value of pi, approximately 3.14159.
EThe base of the natural logarithm, approximately 2.71828.
INFFloating point positive infinity.
NANFloating point not-a-number.

NAN is a floating point number that represents an invalid state. For example, 1/x is a mathematical function that should produce a numeric result. If x is 0 then the numeric result will be not a number, but it will still be represented in floating point for the purpose of storage and future math functions.

For example:

Gamma> x = NAN;
nan
Gamma> 1/x;
nan
Gamma> y = "hello";
"hello"
Gamma> 1/y;
Script error during command: 1/y: Non-number in numeric operation:
    1
    "hello"
    /  from String:1

Math on NAN is legal. It just produces another NAN. Math on strings is illegal. But, in the case of 1/0, we catch that and throw an error. Mathematically the result may be NAN or INF, but in Gamma division by zero is an error. So you cannot use 1/0 to produce a NAN or INF.

Strings

A string may have any number of characters. The special forms \n, \t, \f and \r denote newline, tab, form feed, and carriage return respectively. The double quote (") and backslash (\) characters may be embedded in a string by preceding them with a backslash.

Table 6. Strings
NotationDescriptionExample
" "Contents are a string."Good morning."

Symbols

Generally, symbol names are made up of alpha-numeric characters and underscores.

Table 7. Symbols
NotationDescriptionExample
[a-z,A-Z,0-9]One or more characters chosen from : a-z, A-Z, 0-9 are valid for symbol names.Epax15
_A _ (underscore) is allowed in any part of a symbol name. This symbol is generally used to separate words in a symbol name. The use of this character at the beginning and end of a symbol is reserved for system use.my_var_name
\Any non-alphanumeric character other than _ must be preceded by a backslash to be used in a symbol name.Ft\+\$sq

Other Data Types

The literal representation for all other Gamma data types is discussed in the reference entry associated with creating or accessing that data type, as given in the table below.

Table 8. Other Data Types
Data typeReference entry
Arrayarray
Bufferbuffer
List list
Instance new
Function function
Method method
Class class
File open
Task locate_task