Data Types
In Femscript, there are several built-in data types that allow you to store and manipulate various kinds of data. Each type is designed for a specific purpose, such as representing numbers, text, collections, or custom objects.
Overview of Data Types
Type | Description | Example |
---|---|---|
Str | A sequence of characters representing text. | "Hello, world!" |
Int | An integer or floating-point number. | 69 | 4.2 |
Bool | A boolean value representing truth or falsehood. | true | false |
None | Represents the absence of a value or a NoneType . |
none |
List | A collection of elements, which can include mixed types. | ["example", 69, [1, 2, 3]] |
Scope | A container that encapsulates variables within a defined scope. | { x = 10; y = 20; z = 30; } |
PyObject | A Python object, such as an instance of a class or a callable. | |
Error | Represents an error state, used to convey issues or exceptions. | Error("description") |
Descriptions And Examples
Str
Str is a type used to represent text, enclosed in double quotes.
Example:
Int
Int represents both integer and floating-point numbers.
Example:
Bool
Bool is a boolean type, representing either true
or false
.
Example:
None
None represents the absence of a value. It is useful when you need to signify an "empty" or "unset" state.
Example:
List
List is a collection of elements. It can store mixed types, including other lists.
Example:
Scope
Scope acts as a container for variables and logic. It can be used to group related data.
Example:
PyObject
PyObject allows femscript to interact with Python objects. These can be instances, callables, or any other Python-defined entities.
Python binding example | |
---|---|
- You can find more about binding python objects here
Error
*Error is used to represent issues or exceptions. This type can be returned to indicate a problem during script execution.
Example:
Notes
- Dynamic typing: Femscript is dynamically typed, meaning you do not need to declare types explicitly.
- Type Inference: The interpreter determines the type based on the value assigned.
- Python Interoperability: The PyObject type allows seamless integration with Python, enabling advanced scripting capabilities.