Difference between revisions of "Language Reference/Built-in entities/Domains"
m (link) |
m (subarticle) |
||
Line 336: | Line 336: | ||
All user-defined names of facts sections are the constants of this domain. The compiler automatically builds the corresponding compound terms from such constants whenever it's in need. At the runtime the 1st field of this structure contains the address of the corresponding domain descriptor and the 2nd field contains either zero (for class facts sections) or pointer to an object (i.e. <vp>This</vp>, for object facts sections). | All user-defined names of facts sections are the constants of this domain. The compiler automatically builds the corresponding compound terms from such constants whenever it's in need. At the runtime the 1st field of this structure contains the address of the corresponding domain descriptor and the 2nd field contains either zero (for class facts sections) or pointer to an object (i.e. <vp>This</vp>, for object facts sections). | ||
<noinclude> | <noinclude>{{LanguageReferenceSubarticle|Built-in entities/Domains}}</noinclude> |
Revision as of 10:23, 12 February 2013
any | Universal term type. |
char | Wide (two-bytes) character. |
string | Wide zero-terminated sequence of wide characters. |
string8 | Zero-terminated sequence of ASCII (one-byte) characters. |
symbol | Wide zero-terminated sequence of wide characters. |
binary | Sequence of bytes. |
binaryNonAtomic | Sequence of bytes. |
integer | Integral signed integer number. |
integer64 | Integral signed integer number. |
unsigned | Integral unsigned integer number. |
unsigned64 | Integral unsigned integer number. |
real | Float-pointing number. |
real32 | Float-pointing number. |
pointer | pointer to a memory address. |
handle | a handle (e.g. native file and windows handles). |
boolean | Boolean values. |
factDB | Descriptors of named internal databases. |
compareResult | Values of comparison result. |
any
Universal term type.
any
The values of this domain are any terms. Such a value contains the reference to the term type library and a term itself.
char
Wide character.
char
The values of this domain are UNICODE characters. Implemented as 2 unsigned bytes.
Only assignment and comparison (in the lexicographical sense) operations are applied to the values of this domain. The image of a character has the following syntax:
Char_image : ' Char_value ' Char_value : Letter Digit Graphical_symbol \ Escape_seq Escape_seq: t n r \ ' " u <HHHH>
In the syntax above HHHH correspond to 4 hexadecimal digits. Also, the backslash symbol and the single quote can be represented by an escape-sequence only.
compareResult
The compareResult is a built-in domain. It is used to define a comparison result. The built-in compare/2-> predicate's result is compareResult domain.
domains compareResult = less; equal; greater.
string
Wide zero terminated sequence of wide characters.
string
A string is a sequence of UNICODE characters. It's implemented as a pointer to the wide zero-terminated array of wide characters. Only assignment and comparison (in the lexicographical sense) operations are applied to values of this domain.
In source code a string literal can be specified as a set of sequences of characters surrounded by the double quotes.
StringLiteral: StringLiteralPart-list
StringLiteralPart : @" AnyCharacter-list-opt " " CharacterValue-list-opt "
A string literal consists of one or more StringLiteralPart's, which are concatenated. StringLiteralPart's starting with @ does not use escape sequences, whereas StringLiteralPart's without @ uses the following escape sequences:
- \\ representing \
- \t representing Tab-character
- \n representing newline-character
- \r representing carriage return
- \' representing single quote
- \" representing double quote
- \u followed by exactly four HexadecimalDigit's representing the Unicode character corresponding to the digits.
The double quotes in the string can be represented by the escape-sequence only (the single quote can be represented both with an escape-sequence and a graphical symbol).
string8
A term of the built-in string8 domain is a sequence of ASCII (one-byte) characters. It is implemented as a pointer to the zero terminated array of ASCII characters. Only assignment and comparison for equality (in the lexicographical sense) operations are applied to the values of this domain. Currently no literals are allowed for this domain.
symbol
Wide zero terminated sequence of wide characters.
symbol
Similar to a string, a symbol is also a sequence of the UNICODE characters. It's implemented as a pointer to an entry in a symbol table that contains strings. The operations that can be applied to symbols are the same as for strings.
The image of a symbol is represented with a <string_literal> (any string surrounded by the double quotes).
Symbols and strings are largely interchangeable but they are stored differently. Symbols are kept in a look-up table and their addresses, rather than the symbols themselves, are stored to represent objects. This means that symbols can be matched very quickly and, if a symbol occurs repeatedly in a program, it can be stored very compactly. Strings are not kept in a look-up table. Visual Prolog examines strings character-by-character whenever they are to be matched.
binary
Sequence of N bytes.
binary
Values of this domain are used for holding binary data. A binary value is implemented as a pointer to the sequence of bytes that represents the contents of a binary term.
The length of a binary term is situated in the 4 bytes immediately preceding this sequence of bytes. The 4 bytes contains:
TotalNumberOfBytesOccupiedByBinary = ByteLen + 4
where ByteLen - is the length of the binary term and 4 is number of bytes occupied by size field.
Only assignment and comparison operations are applied to values of binary domain.
Two binary terms are compared in the following way:
- If they are of different sizes, the bigger is considered larger.
- Otherwise, they are compared byte by byte, as unsigned values. Comparison stops when two differing bytes are found and the result of their comparison is the result of the comparison of the binary terms. Two binary terms are equal if they have the same sizes and all bytes are equal.
The text syntax for binary images is determined by the Binary rules:
Binary : $ [ Byte_value-comma-sep-list-opt ] Byte_value : Expression
Each expression should be calculate on compiling time and its value should be in the range from 0 to 255.
binaryNonAtomic
Sequence of N bytes.
binaryNonAtomic
Same as binary, but can contain pointer.
integer
Integral signed number.
integer
Values of this domain occupy 4 bytes. Arithmetic operations (+, -, /, *, ^), comparison, assignment, div/2->, mod/2->, quot/2->, and rem/2-> operations are applied to values of this domain.
The permitted number range is from -2147483648 to 2147483647.
The syntax for the integer literal is determined by the Integer rule:
Integer : Add_operation-opt 0o Oct_number Add_operation-opt Dec_number Add_operation-opt 0x Hex_number Add_operation : + - Oct_number : Oct_digit-list Oct_digit : one of 0 1 2 3 4 5 6 7 Dec_number : Dec_digit-list Dec_digit : one of Oct_digit 8 9 Hex_number : Hex_digit-list Hex_digit : one of Dec_digit a b c d e f A B C D E F
integer64
Integral signed number.
integer64
Values of this domain occupy 8 bytes.
The permitted number range is from -2^63 = -9,223,372,036,854,775,808 to 2^63-1 = 9,223,372,036,854,775,807.
The syntax for integer64 literal is the same as Integer rule.
The set of operations for integer64 is similar to the one for Integer.
unsigned
Integral unsigned number.
unsigned
Values of this domain occupy 4 bytes. Arithmetic operations (+, -, /, *, ^), comparison, assignment, div/2->, mod/2->, rem/2->, and quot/2-> operations are applied to values of this domain.
The permitted number range is from 0 to 4294967295.
The syntax for unsigned number images is the same as for integer numbers. The usage of minus sign (UnaryMinus) is not allowed for an image of an unsigned number.
unsigned64
Integral unsigned number.
unsigned64
Values of this domain occupy 8 bytes.
The permitted number range is from 0 to 2^64-1 = 18,446,744,073,709,551,615.
The syntax for unsigned64 number images is the same as for integer64 numbers. The usage of minus sign (UnaryMinus) is not allowed for an image of an unsigned64 number.
The set of operations for unsigned64 is similar to the one for Unsigned.
real
Float-pointing number.
real
Values of this domain occupy 8 bytes. This numerical real domain is introduced for the user's convenience only. All arithmetic, comparison, and assignment operations are applied to values of real domain.
The permitted number range is -1.7e+308 to 1.7e+308. Values from integral domains are automatically converted to real numbers when necessary.
The syntax for the floating-point number literal is determined by the Real rule:
Real : Add_operation-opt Fraction Exponent-opt Fraction : Dec_number Fractional_part-opt Fractional_part : . Dec_number Exponent : Exp Add_operation-opt Dec_number Exp : e E Add_operation : + - Dec_number : Dec_digit-list Dec_digit : one of 0 1 2 3 4 5 6 7 8 9
real32
Float-pointing number.
real32
Values of this domain occupy 4 bytes. This numerical real32 domain is introduced for the user's convenience only. All arithmetic, comparison, and assignment operations can be applied to values of real32 domain.
The permitted number range is -3.4e+38 to 3.4e+38.
The syntax of real32 literals is the same as real lietrals.
pointer
A pointer to a memory address.
pointer
A pointer directly corresponds to memory addresses. Only the equality operation can be applied to the values of this domain. There is a built-in null constant for this type
handle
A handle is used for Windows API function call. Values of this domain has the same size as a pointer (i.e. 4 on 32bit platfor and 8 on 64bit platform).
There are no operations for this domain and cannot be converted (except uncheckedConvert) to/from other domains.
There is a built-in nullHandle and invalidHandle constant for this type
boolean
Boolean values.
boolean
This domain is introduced for the user convenience only. It is treated as usual compound domain with the following definition:
domains boolean = false(); true().
factDB
Descriptors of named internal databases.
factDB
This domain has the following hidden meta-declaration:
domains factDB = struct @factdb( named_internal_database_domain, object ).
All user-defined names of facts sections are the constants of this domain. The compiler automatically builds the corresponding compound terms from such constants whenever it's in need. At the runtime the 1st field of this structure contains the address of the corresponding domain descriptor and the 2nd field contains either zero (for class facts sections) or pointer to an object (i.e. This, for object facts sections).