Skip to content

Data Types

Risor includes a variety of built-in types. The core types are: int, float, bool, error, string, list, map, set, result, function, and time. There are also a handful of iterator types, one for each container type.

Container types may hold a heterogeneous mix of types within. There is not currently a way to restrict the types a container may hold.

Optional type hints like found in Python or Typescript may be a future addition to Risor.

Quick Reference

101         // int
1.1         // float
"1"         // string
[1,2,3]     // list
{"key":2}   // map
{1,2}       // set
false       // bool
nil         // nil
func() {}   // function  // time

Container Operations

Strings in Risor implement the object.Container interface, which means they support typical container-style operations:

>>> s := "hello"
>>> s[0]
>>> len(s)
>>> s[1:3]
>>> s[1:]
>>> s[:1]
>>> iter(s)
>>> iter(s).next()
iter_entry(0, "h")