Stof
Stof format (application/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!
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.
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
}
Last updated
Was this helpful?