Value module fn
Console program49 lines of .st123 lines of generated Cbuilds as C and Rust
n=2
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "2.2.0"
}
}
}main.st
module "counter" {
source = "./modules/counter"
}
ability "print" "Show" {
message = "n=${module.counter.n}"
depends_on = [module.counter]
}modules/counter/main.st
ability "value" "N" {
type = Int
}
data "value" "N" {
of = ability.value.N
}
ability "function" "Bump" {
body = [ability.set.Inc]
}
ability "set" "Inc" {
target = ability.value.N
value = data.value.N.current + 1
}
ability "call" "First" {
function = ability.function.Bump
}
ability "call" "Second" {
function = ability.function.Bump
}
output "n" {
value = data.value.N.current
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ module.counter.ability.value.N
+ module.counter.ability.function.Bump
+ module.counter.ability.set.Inc
+ module.counter.ability.call.First
+ module.counter.ability.call.Second
+ ability.print.Show
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.c
To inspect this generated file, select C in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runGenerated main.rs (the same .st built as Rust)
To inspect this generated file, select Rust in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd value-module-fn # a folder holding the .st files above
structop init
structop plan
structop apply