Strict Programming Language

Strict Programming Language

  • Games
  • Playground
  • SCrunch
  • Performance
  • Docs
  • VS Code
  • Projects
  • Blog
  • GitHub

›Language

Documentation

  • Overview
  • The VS Code Experience
  • Getting Started
  • Built with Strict
  • Cheat Sheet

Language

  • Types
  • Members and Variables
  • Decimals and Exact Values
  • Methods
  • Tests
  • Statements and Expressions
  • If
  • For
  • Lists and Dictionaries
  • Errors
  • Keywords
  • Grammar

Rules

  • Coding Style
  • Code Validations
  • Naming

Source

  • Base Types
  • Architecture
  • Examples
  • Machine Learning

More

  • Using APIs
  • Concurrency
  • Microservices

Methods

Methods follow the members of a type. A method has a header line that is not indented and a body indented with one tab.

Clamp(minimum = 0, maximum = 1) Number
    1.7.Clamp(0.5, 1.5) is 1.5
    0.3.Clamp is 0.3
    -0.8.Clamp(-0.5, 0.5) is -0.5
    value > maximum then maximum else value < minimum then minimum else value

VS Code shows test timings on method headers and runtime values beside the implementation. Hover over a call to read its signature and tests, or press F12 to inspect its definition.

The header

Name(parameters) ReturnType

  • No parameters, no brackets. Empty () are never written: Floor Number, Run, Close.
  • No return type if the method returns nothing: Run, Delete, Log(text).
  • Parameters are named like members. If the name says the type, the type is left out: Log(text), from(path), Index(other Generic), Substring(start Number, length Number).
  • Default values make parameters optional: Increment(amount = 1), Combine(texts Texts, separator = ", "), IsNearlyEqual(other, difference = Epsilon). A call can leave them out: 0.3.Clamp.
  • Parameters never change. There are no mutable parameters. A method that changes what it is given works on a mutable copy and returns it: Process(image) Image, see Members and Variables.
  • At most 4 parameters. If you need more, the method is doing too much.

Methods may share a name if their parameter types differ. List has both +(other) List (add a list) and +(generic) List (add one element), and Enum has GetName(type) and GetName(member Variable).

The body

  1. Tests first. Every method starts with at least one test line, see Tests.
  2. Then the code. One statement or expression per line.
  3. The last line is the result. return is only needed to leave the method earlier.
Index(other Generic) Number
    (1, 2, 3).Index(2) is 1
    (1, 2, 3).Index(9) is -1
    for elements
        if value is other
            return index
    -1

if and for are expressions too, so a method can end with them. A method that ends with a for loop returns the combined loop result: a list, a sum, a concatenated text, or for a Boolean method, whether any iteration was true. See For.

A method may be at most 13 lines long, including its header and tests. There are no empty lines and no comments.

Computed methods

A header such as Area = Width * Height defines a computed method and infers its return type. It is evaluated when used, like a computed name inside a method. See Members and Variables.

Calling methods

"hello".StartsWith("hel")
2.4.Floor
(1, 2, 3).Sum
Text.Combine(value).ToBrackets
logger.Log("Hi")
Mutable(5).Increment.Decrement.Increment
  • Calls without arguments have no brackets: numbers.Sum, text.Length.
  • Methods and members of the current instance are called directly, without value.: Substring(0, 1).Upper, Length, IsEven.
  • Constants, and methods that don't use any member of an instance, are called through the type name: Text.Combine(...), Character.NewLine, InstructionType.Add.
  • Arguments are separated by ,. A list is written with brackets, so many methods simply take a list: Combine(("a", "b"), "").

Operators are methods

Operators are methods with an operator as their name. They work for your own types exactly like for the base types. From Number.strict:

+(other) Number
    3 + 4 is 7
    value + other
>=(other) Boolean
    0 >= 0
    value >= other

Examples/Register.strict defines arithmetic for a type with three numbers:

has RZero Number
has ROne Number
has RTwo Number
+(other Register) Register
    Register(0, 1, 2) + Register(1, 2, 3) is Register(1, 3, 5)
    Register(RZero + other.RZero, ROne + other.ROne, RTwo + other.RTwo)

Now Register(0, 1, 2) + Register(1, 2, 3) calls this method.

Special methods

MethodPurposeExample
from(...)Custom constructor, called as Type(...)from(text) in Character.strict
to TypeConversion, called as value to Typeto Text, to Number, to Character
is(other)Equality, called as a is b and a is not bis(other) Boolean in Text.strict
in(...)Containment, called as a is in b and a is not in bin(number) Boolean in Range.strict
forDefines how a type is iterated in a for loopfor Iterator(Number) in Range.strict
not, and, or, xorLogic operatorsBoolean.strict
RunEntry point for strict <file> and strict buildExamples/HelloLogger.strict

Any.strict gives every type a default from, to Type, to Text, to HashCode and is.

Methods that change a value

A method that changes its instance returns Mutable(Type) and assigns to value. It can only be called on a mutable value:

Add(element Generic) Mutable(List)
    (1, 2).Add(3) is (1, 2, 3)
    ("a", "b").Add("c") is ("a", "b", "c")
    value = value + element

See Members and Variables for why this still doesn't change any value.

Methods without a body

Trait methods have only a header. The type that has the trait implements them, see Traits. A few base methods without a body, like Directory.Exists or File.Delete, are implemented by the native runtime.

Last updated on 10/17/2026 by Benjamin Nitschke
← Decimals and Exact ValuesTests →
Strict Programming Language
Docs
The VS Code ExperienceGetting StartedBuilt with StrictLanguage GuideCheat SheetCoding Style
Source
Base TypesArchitectureExamplesQwen3 and Machine LearningC and C# Interop
More
BlogGitHubIssuesVS Code ExtensionWebsite SourceStar
Copyright © 2026 strict-lang