Macro
Console program28 lines of .st113 lines of generated C
The sum of 5 and 2 is 7 The sum of 3 and 7 is 10
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
}
}main.st
ability "macro" "ADD" {
params = [{ name = "a", type = Int }, { name = "b", type = Int }]
returns = Int
value = a + b
}
ability "print" "First" {
message = "The sum of 5 and 2 is ${ADD(5, 2)}"
}
ability "print" "Second" {
message = "The sum of 3 and 7 is ${ADD(3, 7)}"
depends_on = [ability.print.First]
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.macro.ADD
+ ability.print.First
+ ability.print.Second
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-runTry it
cd c-macro # a folder holding the .st files above
structop init
structop plan
structop apply