# Stof

Stof language is implemented as a Stof format, just like the others (JSON, YAML, TOML, etc.). This makes it available to use with `Std.parse(..)` also!

{% hint style="info" %}
Check out [Custom Embedded](/advanced-features/custom-embedded.md) and [Imports](/advanced-features/imports.md) for more information.
{% endhint %}

{% hint style="warning" %}
You might be thinking there must be security concerns with this. However, the host environment (running Stof) has complete and sandboxed control over libraries, which is the only way Stof can interact with that machine.

This opens up use cases across systems where you could send an API to be used (functions, schemas, types, etc.) in addition to data.
{% endhint %}

{% tabs %}
{% tab title="main.stof" %}

```rust
import "./data"

#[main]
fn main() {
    assert_eq(self.message, "hello, world");
    assert_eq(self.person.name, "Bob Smith");
    assert_eq(self.person.age, 42);
    
    const stof = r#"
        parsed: true

        fn say_hi(name: str) -> str {
            `Hi, ${name}`
        }
    "#;
    const container = new {};
    parse(stof, container, "stof"); // parse just like any other format

    assert(container.parsed);
    assert_eq(container.say_hi("John Snow"), "Hi, John Snow");
    drop(container); // can remove from the doc when you're done
}
```

{% endtab %}

{% tab title="data.stof" %}

```rust
message: "hello, world"
person: {
    name: "Bob Smith"
    age: 42
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Challenge: what if `drop(this)` is called within a function? The "this" references the current function as a "fn" pointer, so it would work just fine, removing the currently executing function from the document (surprisingly helpful in some cases).

In Stof, everything is data and can be manipulated as such, including the currently running environment.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stof.dev/formats/stof.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
