Type and Shape¶
Even though ELI does not require explicit type for declaring a variable, it needs types for every computation internally. Moreover, a variable with a specific type at one time is assigned with a shape as well.
* Note: Currently, null value is only available in Boolean, Integer, Float, Char, Symbol and List.
The types can be classified into the following two groups.
- Basic types:
boolean, integer, float, char, complex, symbol, month, date,datetime, minute second, time
- Advanced types:
list, enumeration, dictionary, keyed table and table
ELI follows some conventional type rules while new type rules because of new advanced types. ELI does not implicitly do casting for the result after one computation. Instead, ELI leaves it to developers that makes the system more consistent.
- The arithmetic operations between boolean, int and double are the same as common languages such as C and Java.
- Primitive functions like circle can generate complex numbers even input
data is not a complex number. For example,
_1*.0.5(equivalent to sqrt(-1)) is
- Table and dictionary can be transformed from each other if conditions are
satisfied. (Check the primitive function
There are 7 basic shapes for basic types.
|scalar||x <- 2||shape(x) => empty|
|one-item vector||x <- ,2||shape(x) => 1 (1-dim)|
|vector||x <- 1 2 3||shape(x) => 3 (1-dim)|
|matrix||x <- 2 2#1 2 3 4||shape(x) => 2 2 (2-dim)|
|high-dimension||x <- 2 2 2#!8||shape(x) => 2 2 2 (3-dim)|
|list||x <- (1 2; 2.5 9; ‘hello’)||shape(x) => 3 (the length of the list)|
|table||x <- (int<-1 2;flt<-2.3 5)||shape(x) => 2 (row of the table)|
* Note: For advanced types, they are formed by list and table shapes. And the two shapes are based on other basic types.