Passing arguments by value
Circuit functions accept arguments from public and private input files. These arguments cannot contain memory addresses as there is no guarantee that an address will be valid when a circuit is eventually run.
As a result, arguments passed to circuit functions should be passed by value rather than by reference.
The following examples contain examples of passing by value and passing by reference.
- C++
- Rust
bool passing_by_reference(int *x) {}
bool passing_by_value(int x) {}
fn passing_by_reference(x: &mut i32) -> bool {}
fn passing_by_value(x: i32) -> bool {}