Value type order
Console program48 lines of .st121 lines of generated Cbuilds as C and Rust
a=7 l=green q=1
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "2.2.0"
}
}
}a.st
ability "value" "P" {
type = Pair
initial = {
a = 3
l = Light.green
}
}
data "value" "P" {
of = ability.value.P
}
variable "q" {
type = Pair
default = {
a = 1
l = Light.red
}
}
ability "set" "Grow" {
target = ability.value.P.a
value = data.value.P.current.a + 4
}
ability "print" "Show" {
message = "a=${data.value.P.current.a} l=${data.value.P.current.l} q=${var.q.a}"
}z.st
ability "enum" "Light" {
values = [red, amber, green]
}
ability "struct" "Pair" {
fields = [{ name = "a", type = Int }, { name = "l", type = Light }]
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.value.P
+ ability.set.Grow
+ ability.print.Show
+ ability.enum.Light
+ ability.struct.Pair
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-type-order # a folder holding the .st files above
structop init
structop plan
structop apply