Datatypes in SRON

Data types represent the different kinds of values that variables and expressions can hold or represent.


There are 10 datatypes available in SRON:

1. Int :

  • Represents whole numbers without decimal parts.\

  • Examples include 0, 1, -5, 1000.\

  • Range of 'Int' is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

  • 'Int' keyword is used to declare Int-type variables.

{
    name : Main

    Int val = 10

    val = -155
}

2. Double :

  • Represents numbers with fractional parts. It can hold upto 15 floating point decimal digits.

  • Examples include 3.14, -0.001, 2.71828.

  • Range of 'Double' is from 2.22507385850720138309023271733240406e-308 to 1.79769313486231570814527423731704357e+308.

  • 'Double' keyword is used to declare Double-type variables.


3. Char :

  • Represents single characters, such as letters, digits, and symbols. Character data types are used to store individual characters from a character set (e.g., ASCII, Unicode).

  • Examples include A, B, \n , \t, 1, 2 etc.

  • 'Char' keyword is used to declare Char-type variables and single apostrophe (') is used to make a Char-type values.


4. String :

  • Represents sequences of characters. Strings are used to store text or sequences of characters, such as words, sentences, or paragraphs.

  • String-type values can contain only ASCII characters.

  • 'String' keyword is used to declare String-type variables and quote mark (") is used to make a String-type values.


5. Bool :

  • Represents logical values of true or false. Boolean data types are commonly used in conditions and logical operations.\

  • Contains only two values 'true' or 'false'.

  • 'Bool' keyword is used to declare Bool-type variables.


6. List :

  • Represents a sequence of all the above data types in a single unit.

  • It can even store a List type in itself also.

  • List variables are declared using 'List' keyword and 'List' are declared using Square brackets '[ ]'.


7. Collective :

  • We cannot directly call Collective a datatype because you cannot create its variable. In the internal functioning of SRON, the 'String', 'LiteralString' and 'List' types are the child types of Collective.

  • In other words, Collective is a datatype which is able to store more than one value within itself. Like String which can store many characters within itself. List is also a collective type because it can store more than one values within itself.


8. FileReader :

  • Used to read the content of a file in the secondary storage(or disk).

  • FileReader variables are declared using 'FileReader' keyword.


9. FileWriter :

  • Used to write the content to a file in the secondary storage(or disk).

  • FileWriter variables are declared using 'FileWriter' keyword.


10. LiteralString :

  • used to read the compile time strings without copying them.

  • it is immutable so cannot perform changes to it's content.


Last updated