Cind language documentation

Data types

A data operated by the Cind language are objects of system types (described below), objects of defined classes (see Classes), functions (see Functions), arrays (see Arrays), vectors (see Vector of values), and external objects (see External objects).
System types are: int, string, bool, char, byte, float, fun and sheet.

Every value is treated as an object, which can be stored in variable and responds to messages and operators.
For methods accepted by values and allowed type conversion see Methods of the system type objects.
For type conversion methods see Type conversion.

Integer number - int

int x = 3;

Value of type int is an integer number from -9223372036854775808 to 9223372036854775807.
Its internal representation is a 64-bit (8 bytes) register.
Notation allows decimal, hexadecimal and binary form. Examples of notation:

0 123 -234 0X4f5a -0xFEDCBA987654321 0b110010

Accepted operations: ++ -- ! ~ + - * / % == != > < >= <= >> << & | ^ (see Operators).
When result of operation failed or reached out of integer's range, then there will be an exception thrown.

Text value - string

string s = "Hello! XD";

Text inserted between quotation marks " ... " is interpreted as string object (single quotes ' ... ' are also allowed).
Compiler reads text characters in UTF-8 charset (where first 128 bytes are ANSI characters).

Supported escape chars:

\a \b \f \n \r \t \v - special text control characters \\ \' \" \? - backslash is used to put those chars inside text \nnn - octan value (using 3 digits 0..7) including \0 \xHH..H - hexadecimal value of character 0 - 7FFFFFFF \uXXXX - unicode short (needs 4 hex digits) \UXXXXXXXX - unicode large (needs 8 hex digits)

Operator + glues two strings and create new string object. Examples:

"ab" + "cd" // = "abcd" "2" + 3 // = "23", because 3 will be converted to string and then added 2 + "3" // = 5, because "3" will be converted to int

Boolean value - bool

bool a = true;

A boolean value could be the one of two values: true or false, which represents two states of logic expression.

Accepted operations: == != ! && || (see Operators).

Character - char

char c = 'a'; char e = 0x0A;

Char object represents one text character.
There are no explicit notation of char, but in above examples, string 'a' and integer 0x0A will be maped to char objects during assigning to variables.
Every character can has unicode value from 0 to 0x7FFFFFFF.

Accepted operations: ++ -- + - == != > < >= <= (see Operators), which works on char's unicode value.
Operations + and - expects integer second argument.

Byte - byte

byte b = 0xFA;

Byte value represents 8-bit register. Its integer value can be from 0 to 255.
There are no explicit notation of byte, but in above example, integer 0xFA will be maped to byte during assigning to variable.

Accepted operations: ++ -- ! ~ + - * / % == != > < >= <= >> << & | ^ (see Operators).
When result of operation reached out of byte's range, then it will be converted modulo 256 to fit in byte's register,
and (unlike as in int type) an exception will not be thrown.

Floating point number - float

float e = 2.7182818284590452;

Type float is a 64-bit floating point number representation (standard IEEE 754).
In 64 bits, there are 1 bit of sign, 52 bites of mantissa and 11 bites of exponent in base 2.

Examples of notation:

0.0 // 0 in float type 123.0 // 123 in float type -1.2595 // -1.2595 2f // 2.0 -2.5f // -2.5 .5 // 0.5 -.40 // -0.4 6e2 // 6*10^2 = 600.0 1.5e3 // 1.5*10^3 = 1500.0 3.4e-3 // 3.4*10^-3 = 0.0034

Accepted operations: ++ -- ! + - * / % == != > < >= <= (see Operators).

Float object has also special methods binaryRep and fromBinaryRep to convert number to array of 8 bytes of its standard 64-bit representation:

byte[] x = f.binaryRep(); // x will be an array of 8 bytes float y = f.fromBinaryRep([0x80,0,0,0,0,0,0,1]); // y will be -1.0

Function - fun

fun f;

Functions as also treated as objects, which can be handled as values of fun type.
For more about functions see Functions.

Binary data - sheet

sheet h;

Sheet object is a set of bytes, which represents the managed part of the memory.
For more info see Sheet object.



Cind programming language 1.0.4

 

Advertisements