References
If a function argument is immutable (like foo in the examples above)
V can pass it either by value or by reference. The compiler will decide,
and the developer doesn't need to think about it.
You no longer need to remember whether you should pass the struct by value or by reference.
You can ensure that the struct is always passed by reference by
adding &:
foo is still immutable and can't be changed. For that,
(mut foo Foo) must be used.
When immutable reference parameters to structs are compared with == or !=,
V compares their addresses, not their fields. Dereference the parameters explicitly
to compare their values instead:
This address-comparison rule also applies when reference parameters are captured by
a closure or their reference types are written through aliases. A user-defined ==
operator takes precedence over the default address or value comparison.
In general, V's references are similar to Go pointers and C++ references. For example, a generic tree structure definition would look like this:
To dereference a reference, use the * operator, just like in C.