Types and Values
lash is dynamically typed. Variables do not carry type annotations; their type is determined at runtime by the value they hold.
Supported Types
Section titled “Supported Types”| Type | Example |
|---|---|
string | let greeting = "hello" |
int | let count = 42 |
float | let ratio = 3.14 |
bool | let verbose = true |
list | let files = ["a.txt", "b.txt"] |
object | let config = { editor: "vim", tabs: 4 } |
semver | let ver = semver("1.2.3") |
Type Bounds
Section titled “Type Bounds”Every type defines .min and .max properties:
| Type | .min | .max |
|---|---|---|
int | -9223372036854775808 | 9223372036854775807 |
float | -1.7976931348623157e+308 | 1.7976931348623157e+308 |
string | "" (empty string) | undefined |
bool | false | true |
list | [] (empty list) | undefined |
object | {} (empty object) | undefined |
Semver Type
Section titled “Semver Type”The semver() constructor parses a semantic version string and returns a tagged object:
let ver = semver("1.2.3-beta+build.42")| Field | Type | Description |
|---|---|---|
major | int | Major version number |
minor | int | Minor version number |
patch | int | Patch version number |
prerelease | string | Pre-release identifier (may be "") |
build | string | Build metadata (may be "") |
The object carries a hidden __type entry (value "semver") excluded from keys() output. Comparison operators follow semver 2.0 precedence rules. String representation: MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD].
Universal Properties
Section titled “Universal Properties”These properties are available on all value types:
.isSuccess— Returnstrueif the value is “successful”. For command capture results, checks exit code == 0. For other values, returns truthiness..isFailure— The inverse of.isSuccess.
Collection Literals
Section titled “Collection Literals”List Literals
Section titled “List Literals”let items = [1, 2, 3]let mixed = ["hello", 42, true]Lists can hold values of any type, including mixed types.
Object Literals
Section titled “Object Literals”let config = { host: "localhost", port: 8080 }Object Property Access
Section titled “Object Property Access”Bracket syntax and dot syntax are both supported:
config["host"] # bracket accessconfig.host # dot access (when key is a valid identifier)Dot access on objects resolves the key name as a property lookup. It must not collide with built-in method names — use bracket syntax when a key matches a method name.
Range Expressions
Section titled “Range Expressions”let nums = 1..10 # produces [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]Ranges produce integer lists and are usable anywhere a list is expected.