Module typedef

Source
Expand description

Type definitions for the AIM expression grammar.

This module provides type definitions and parsing for the type system used in the AIM expression language. It includes basic types like Bool, Date, Number, Task, and Text, as well as array variants and special types like Closure, Eval, Format, and Node.

The Typedef enum represents the complete type system for AIM expressions, supporting type checking, casting operations, and function signature validation. Type definitions are used throughout the expression evaluation system to ensure type safety and enable automatic type promotion.

§Supported Types

§Basic Types

  • Any - Any type (wildcard type that matches any value)
  • Bool - Boolean values (true/false)
  • Date - Date and time values
  • Number - 64-bit floating point numbers
  • Task - Task primitives with status and text
  • Text - String values

§Array Types

  • Any[] - Array of any values (heterogeneous)
  • Bool[] - Arrays of boolean values
  • Date[] - Arrays of date values
  • Number[] - Arrays of number values
  • Task[] - Arrays of task values
  • Text[] - Arrays of text values

§Special Types

  • Closure - Closure expression type (anonymous functions)
  • Eval - Evaluation results (inference output)
  • Format - Formatting instructions (output formatting)
  • Node - Node references (workflow references)

§Type Promotion Rules

AIMX uses an intuitive type promotion strategy where the left operand’s type generally dictates the conversion for the right operand. This allows for expressive, convenient formulas while preserving type safety.

§Examples

// Type casting examples
(Bool)true        // cast to boolean
(Number)"123"     // cast to number
(Text[])items     // cast to text array

// Function signature examples
task.done()       // requires Typedef::Task
numbers.sum()     // requires Typedef::NumberArray
text.upper()      // requires Typedef::Text

§Usage

Type definitions are primarily used for:

  • Type casting operations in expressions
  • Function signature validation
  • Method dispatch based on receiver type
  • Type checking during expression evaluation

See also: parse_typedef, parse_literal_type, Typedef

Enums§

Typedef
Represents type definitions in the AIM expression grammar.

Functions§

parse_literal_type
Parse a literal type definition from a string.
parse_typedef
Parse a type definition from a string according to the AIM expression grammar syntax.