Calls
Workbenches and functions can get called, which just means there inner code gets executed. There are several types of calls which have some different effects or usage.
| Call... | Example | Input(s) | Output |
|---|---|---|---|
| function | value = my_function(..); | parameter list | Value |
| workbench | model = MySketch(..); | parameter list | Model1 |
| operation | new_model = model.my_operation(..); | Model1 & parameter list | Model1 |
Calling Functions
A call of a function consists of just the identifier and an argument list. and the result is a value:
// call function -2 and store result in x
x = std::math::abs(-2);
// check value
std::debug::assert_eq([x, 2]);
Calling Workbenches
Workbenches can be called in the same way as functions except that the result is a model.
// call sketch Circle with a size and store object node in s
s = std::geo2d::Circle(diameter = 2cm);
std::debug::assert_eq([s.radius, 1cm]);
Calling Operations
Operations are called in a different way because they are always attached to a model which come out of workbenches.
// call square with a size and store object node in s
s = std::geo2d::Circle(radius = 2cm);
// translate object s
s.std::ops::translate(x = 1cm);
Surely this looks better when using thw use statement.
// use translate
use std::ops::translate;
// call square with a size and store object node in s
s = std::geo2d::Circle(radius = 2cm);
// translate object s
s.translate(x = 1cm);