Stof Docs
Star on GitHubStof WebsiteDiscordContact Us
  • ๐Ÿš€Welcome
  • โ„น๏ธResources & Information
  • Book
    • Data Interface
    • Introduction & Design
    • Host Environments
      • Rust
      • TypeScript
        • Extend Stof
        • Import Statement
    • Data Interchange
      • JSON to Stof
      • Importing and Parsing Data
      • Exporting Data
      • REST and Restructure
    • Configuration Files
    • Schemas
      • Renaming Fields
      • Removing Fields
      • Validation & Transformation
        • Example Access
      • Nested Schemas
    • Orchestration
  • Common Concepts
    • Objects
    • Primitive Types
    • Functions
    • Fields
    • Object Types
    • Imports
    • Error Handling
    • Units
    • Casting/Conversions
  • Reference
    • CLI
      • ๐ŸƒRun
      • ๐ŸงชTest
      • ๐Ÿ“šCLI Libraries
        • Filesystem Library
        • Time Library
        • HTTP Library
    • Stof Language
    • Libraries
      • Standard Library
      • Array/Vector Library
      • Number Library
      • String Library
      • Object Library
      • Function Library
      • Set Library
      • Map Library
      • Data Library
      • Tuple Library
      • Blob Library
      • Boolean Library
    • ๐ŸชงFormats
Powered by GitBook
On this page

Was this helpful?

  1. Reference

Libraries

Libraries enable the inner workings of Stof as well as Stof's access to the outside world. Libraries should never travel with Stof between systems - it is up to the host environment to dictate what Stof has access to.

Host systems can add, remove, or replace libraries to extend and control Stof. By default, Stof comes with libraries for its types and a standard library for some common functionality.

See CLI Libraries for additional libraries that get added by the Stof CLI. These additional libraries (or your own libraries) can be added or replicated in your embedded environments.

To call into a library that the Stof document has loaded, simply reference it by name. For Stof types, this is done automatically when a variable is used:

fn example() {
    let x = 2.pow(3);          // reference the "Number" library based on value type
    let y = Number.pow(2, 3);  // explicitly reference the "Number" library
    
    assertEq(x, y);     // automatically reference the library named "std"
    std.assertEq(x, y); // explicitly reference the standard library "std"
}
PreviousStof LanguageNextStandard Library

Last updated 3 months ago

Was this helpful?