YREA-SLS/docs/overview.md

2.7 KiB

Title Prev Next
YREA SLS | 1 Overview Lexical Structure Index

1. Overview

A statically-typed, stack-based language with pure postfix notation combining the execution model of HP's RPL, the type system of C and Rust, and modern array operations from Uiua.

Design Principles

  • Everything is postfix - no exceptions
  • Stack-based execution (no local variables)
  • Static typing with type inference
  • Manual heap memory management (future feature)
  • Types define what things are, traits define how things act
  • All constructs are implicitly generic
  • Every operator is defined by a trait

Operators vs Functions

Operators are operations that implement trait methods. They can be:

  • Built-in primitive operations provided by the language
  • User-defined operations implementing custom trait methods
  • Library-defined operations
  • All operators must be backed by a trait
  • Cannot share names with functions
  • Are the fundamental building blocks of the language
  • Examples: +, -, dup, swap, if, while (built-in); custom operators via trait implementation

Functions are user-defined or library-defined procedures. They:

  • Do not implement traits directly (though they may use operators that do)
  • Cannot share names with operators
  • Are defined using the fn operator
  • Examples: factorial, fizzbuzz, square

Naming Rule: Once a name is used for either an operator or a function, it cannot be reused for the other category.

Document Organization

This specification is organized to support both learning and reference:

Sections 1-7 cover the fundamentals needed to write basic programs:

  • Lexical structure, primitive types, basic operations
  • Functions and control flow
  • Data structures

Sections 8-10 cover intermediate concepts:

  • Type system formalization
  • Trait system for behavioral contracts
  • Generic programming

Section 11 covers advanced topics:

  • Dynamic code evaluation
  • Identifier literals
  • Standard library overview

Appendices provide complete references:

  • A: Standard Library (alphabetical reference)
  • B: Complete Trait Reference (all trait definitions)
  • C: Complete Operator Reference (all operators)
  • D: Grammar Summary
  • E: Module System (future)
  • F: Memory Management (future)
  • G: Examples & Tutorials

Reading Guide

New users: Start with Sections 1-7 to learn the language basics. Work through the tutorials in Appendix G as you go.

Experienced programmers: Skim Sections 1-4, focus on Sections 5-11 for language-specific features.

Implementers: Read all sections, paying special attention to Sections 8-10 and Appendices B-D for complete specifications.

Reference lookup: Use Appendices A-C for quick reference to standard library functions, traits, and operators.