Language Reference/Built-in entities/Domains

From wiki.visual-prolog.com

< Language Reference‎ | Built-in entities

Revision as of 13:33, 12 November 2023 by SergeMukhin (talk | contribs) (remove ())
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 32 bit signed integer.
integer64 64 bit signed integer.
integerNative Signed integer with platform size (32 bit in a 32 bit program; 64 bit in a 64 bit program).
unsigned 32 bit unsigned integer.
unsigned64 64 bit unsigned integer.
unsignedNative Unsigned integer with platform size (32 bit in a 32 bit program; 64 bit in a 64 bit program).
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 result of a comparison. For instance, the built-in procedure compare/2-> has "compareResult" as the domain of its result.

domains
   compareResult = less; equal; greater.

string

Utf-16 strings.

string

A string represented as a pointer to a zero terminated sequence of characters in utf-16 encoding. Values in the sequence are 16 bits, but certain rare characters (code points) are encoded using two such values. Strings are immutable.

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 built-in domain who's elements are sequences of (one-byte) ASCII-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

Utf-16 strings with same representation as string, but they are also stored in a global symbol table.

symbol

A symbol is stored in a global symbol table, and that storage guarenties that the pointer value of symbols will be the same for the same symbol. Once a symbol is put into the symbol table it is never removed again, so symbols are never reclaimed. Their storage will live untill the program terminates. So the symbol data type should not be used for large documents, etc.

The symbol domain is a subtype of the string domain, so a symbol can be used everywhere instead of a string. The opposite is not the case because a string will have to be found or inserted in the global symbol table to become a symbol. So to create a symbol from a string you will have to convert the string to the symbol domain (or a subtype of the symbol domain).

The equality operation is very efficient for symbols since their pointer value will be the same if the symbol is the same. I.e. there is no need to compare the actual characters to determine equality.

Other comparison operations (less than, case insensitive comparison, etc) are the same as for string in fact all other operations on symbol is simply carried out by the corresponding string operations.

binary

Sequence of 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 bytes.

binaryNonAtomic

Same as binary, but can contain pointers because it is scanned by the garbage collector.

integer

32 bit signed integer.

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

64 bit signed integers.

integer64

Values of this domain occupy 8 bytes.

The permitted number range is from -2^63 = -9223372036854775808 to 2^63-1 = 9223372036854775807.

The syntax for integer64 literal is the same as Integer rule.

The set of operations for integer64 is similar to the one for Integer.

integerNative

Signed integer number with platform size (32 bit in a 32 bit program; 64 bit in a 64 bit program).

integerNative

unsigned

32 bit unsigned integer.

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

64 bit unsigned integer.

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.

unsignedNative

Unsigned integer number with platform size (32 bit in a 32 bit program; 64 bit in a 64 bit program).

unsignedNative

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

pointerTo

pointerTo{Type} represents a pointer to a value of type Type. It's definition is like this (but it is built-in):

domains
    pointerTo{Type} = pointerTo(Type Value).

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