Types System¶
EasyLang uses a simple, beginner-friendly type system designed to feel natural and readable.
Although the language looks like English, every value in EasyLang still has a type behind the scenes.
EasyLang types are based on:
- native EasyLang values
- Python types wrapped for EasyLang
- module namespaces
This chapter explains all supported types, how they behave, how they interact, and common mistakes to avoid.
Overview of Types¶
EasyLang supports the following built-in types:
Number¶
String¶
Boolean¶
List¶
Dictionary¶
Module¶
Python-Wrapped Object¶
Null (implicit return value)¶
1. Number¶
Numbers include integers and floats:
10
3.14
0.001
Examples:
we let x = 10
we let y = 3.5
we let z = x mul y
Supported operations:¶
| Operation | Example |
|---|---|
| addition | x plus y |
| subtraction | x minus y |
| multiplication | x mul y |
| division | x div y |
| comparison | x greater 10, x equals 5 |
You may also use symbol forms like `+, -, *, /.
2. String¶
Strings are enclosed in double quotes:
"hello"
"EasyLang"
Examples:
we let name = "GreenBugX"
so print name plus " is awesome"
String operations¶
| Operation | Description |
|---|---|
plus |
concatenation |
.upper() |
uppercase |
.lower() |
lowercase |
.strip() |
trim whitespace |
.substring(start, end) |
substring |
.contains(value) |
check presence |
Example:
bring strings as s
so print s.upper("easy")
3. Boolean¶
Supported boolean literals:
true
false
Examples:
if logged_in equals true then [...]
Logical operations:
and
or
not
Example:
if age greater 18 and has_id then [
so print "Allowed"
]
4. List¶
Lists store ordered values:
[1, 2, 3]
["a", "b", "c"]
Examples:
we let nums = [1, 2, 3]
nums.push(4)
so print nums.len()
List methods¶
| Method | Description |
|---|---|
.push(x) |
append value |
.pop() |
remove last value |
.len() |
length of list |
.join(sep) |
join to string |
Lists may contain mixed types:
[1, "hi", true, [2, 3]]
5. Dictionary (Object)¶
Dictionaries use {} and store key–value pairs:
{
"name": "GreenBugX",
"age": 16
}
Access using dot notation:
so print user.name
so print user.age
Nested dictionaries:
config.database.port
6. Module¶
Modules are special namespaces created by:
bring module as alias
Example:
bring "math.elangh" as math
so print math.sqrt(25)
A module is essentially a dictionary-like container holding:
- functions
- variables
- constants
Modules have their own internal scope.
7. Python-Wrapped Objects¶
One of EasyLang’s strongest features is Python interoperability.
You can import any Python module:
bring math as m
bring random as r
bring os as o
These become Python-wrapped objects, which support:
- method calls
- attribute access
- number/string values
- function invocation
Example:
bring os as o
so print o.getcwd()
Another example using ELPM:
elpm --install requests
In EasyLang:
bring requests as req
we let r = req.get("https://httpbin.org/get")
so print r.text
8. Null¶
null is not a literal in EasyLang, but it appears when:
- a function ends without a return
- a Python function returns None
- an invalid operation yields nothing
Example:
define f(): do [
so print "hi"
] $ no return → null
Usage:
we let x = f()
so print x $ prints: null
Type Checking Rules¶
EasyLang automatically checks for invalid type combinations.
Examples:
❌ invalid arithmetic
"hello" mul 3
Result:
RuntimeError: Unsupported operand types for mul: string and number
❌ string + number
RuntimeError: Unsupported operand types for plus: string and number
✔ valid
"hello " plus "world"
10 plus 5
Mixed-Type Expressions¶
Some Python wrappers allow mixed behavior (e.g., JSON objects, numpy arrays), but for EasyLang types:
| Operation | Allowed? |
|---|---|
| number + number | ✔ |
| string + string | ✔ |
| number + string | ❌ |
| list + list | ❌ |
| list.push(value) | ✔ |
| dictionary access | ✔ |
| call method on wrong type | ❌ |
Example wrong type:
10.upper()
Output:
RuntimeError: Object has no attribute 'upper'
How Types Are Stored Internally¶
EasyLang stores variables in Environment objects (nested scopes).
Values inside these scopes are:
- Python integers, floats → for numbers
- Python strings → for EasyLang strings
- Python lists/dicts → for EasyLang lists/dicts
- Wrapped Python modules → for imported Python modules
- Module namespaces → for
.elanghmodules
Because of this, many operations behave similarly to Python (but are wrapped with safe checks and error messages).
Type Conversion¶
Built-in conversions:
int(x)
float(x)
str(x)
Examples:
so print int("10")
so print float("3.14")
Summary¶
EasyLang types are simple, practical, and deeply integrated with Python’s own type system.
Supported types:
- Numbers
- Strings
- Booleans
- Lists
- Dictionaries
- Modules
- Python-wrapped objects
- Null
These types interact predictably and safely, with helpful runtime errors when mistakes occur.