Types in the Oils Runtime - OSH and YSH

Here are all types of values in the Oils runtime, organized for understanding.

Table of Contents
Nine Atoms
Serialiable
More
Six Containers
Obj is for User-defined Types
Five Units of Code
Four Types for Reflection
Appendix
The JSON Data Model
Why Isn't Everything an Object?
Implementation Details
Related

Nine Atoms

Values of these types are immutable:

Serialiable

More

Six Containers

Obj is for User-defined Types

Objects allow polymorphism. See YSH Objects.

Examples of Objects

Modules and types are represented by Obj instances of a certain shape, not by primitive types.

  1. Modules are Obj instances with attributes, and an __invoke__ method.
  2. Types are Obj instances with an __index__ method, and are often compared for identity.

In general, Objects are mutable. Do not mutate modules or types!

Five Units of Code

Values of these types are immutable:

Four Types for Reflection

Appendix

The JSON Data Model

These types can be serialized to and from JSON:

Why Isn't Everything an Object?

In YSH, the Obj type is used for polymorphism and reflection.

Polymorphism is when you hide different kinds of data behind the same interface.

But most shell scripts deal with concrete textual data, which may be JSON-like or TSV-like. The data is not hidden or encapsulated, and shouldn't be.

Implementation Details

These types used internally:

Related

Generated on Sat, 14 Jun 2025 23:51:39 +0000