The expression adds one to the supplied x value. Parse the expression and input separately, build the program once, and evaluate it with a native document. The input and result remain documents until you choose to serialize them.

Build an expression and evaluate it

expressionText holds this document:

dust9B
[+ ?x 1]

inputText holds this document:

dust5B
x 41
go422B
expression, err := stardust.Parse(expressionText, stardust.DUST)
if err != nil {
	return err
}
defer expression.Close()

input, err := stardust.Parse(inputText, stardust.DUST)
if err != nil {
	return err
}
defer input.Close()

program, err := stardust.Build(expression, nil)
if err != nil {
	return err
}
defer program.Close()

result, err := program.Evaluate(input, nil)
if err != nil {
	return err
}
defer result.Close()
Result / 2B
42

The captured result is 42. Release the result, program and parsed documents when finished. A retained program can evaluate further inputs. See Expressions and macros.