Basic data types
They are:float
— type of double precision (64-bit) floating point numbersint
— integer numbersbool
— boolean valuesTrue
orFalse
str
— string data type
indie.Optional[T]
class
In Indie (unlike in Python) it is not allowed to assign None
value to a variable of any arbitrary type (e.g. basic
data types). But it is allowed to do so with the help of indie.Optional[T]
class.
indie.Optional[T]
is similar to Python’s typing.Optional[T]
with a few significant differences:
None
can be assigned to values which haveindie.Optional[T]
type only.None
cannot be assigned to values of someT
type which is not an optional type- to write some value to an optional variable just simple assignment operator should be used
- to access
T
value which is stored inindie.Optional[T]
it is required to explicitly callvalue()
orvalue_or()
method - if
value()
method is called on an optional variable which isNone
it raises runtime error - to test if optional variable has some value stored inside
is None
andis not None
constructs should be used - if variable was declared as
indie.Optional[T]
thenT
cannot be changed for that variable to some other typeU
T
type for a
in this example. Yes, it may guess that a
is of indie.Optional
type,
but it is unclear how to guess that T
will be an int
for it.
This will not work too:
a
is not an optional type, so None
cannot be assigned to it.
That is why type of a
must be declared explicitly as an optional type:
a
was declared as optional of int
value, it cannot at some point start to store str
values.
By the way if you do not assign any value to an optional variable it will be None
too:
a
and b
in this example are None
.
To check if optional variable a
is None
or not we use:
a
, the value()
method should be explicitly called:
value()
method call raises a runtime error. For example:
'foobar'
is stored in optional variable s
.
Built-in container types
At the moment (Indie v4) onlylist[T]
is implemented in the Indie language. There are partial support of a tuple[T]
.
It is planned to add support for dict[K, V]
and set[T]
in the near future.
Series data types
indie.Series[T]
and an aliasindie.SeriesF
forindie.Series[float]
indie.MutSeries[T]
and an aliasindie.MutSeriesF
forindie.MutSeries[float]
Series[T]
is a read-only container which stores series of T
values. MutSeries[T]
extends Series[T]
with only
__setitem__
method, which allows writing to the last element of the container (which syntactically looks like
some_mut_series[0] = some_value
).
Type T
can be (almost) any type in Indie, not just float
, but also int
, bool
, str
, etc.
Context data types
There are three context classes:indie.Context
is a base class that represents a context of a chart instrumentindie.MainContext
is a class that represents main context, extendsindie.Context
indie.SecContext
is a class that represents secondary context, extendsindie.Context
Algorithm base class
There is aindie.Algorithm
base class. All algorithms from indie.algorithms
package are inherited from it.