Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions content/docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,32 @@ odds := []int{1, 3, 5}
fmt.println(sum(..odds)) // 9, passing a slice as varargs
```

**Note:** Odin makes a compromise for the sake of performance in that large arguments (as determined by the compiler) are internally passed by reference (as opposed to always copying them to the stack, as C does) and this can have surprising consequences if you are not aware of it. Here's an example:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now defined as always >16 bytes now. <= 16 bytes will always be "pass by value".

```odin
package main

import "core:fmt"

Data :: struct {
number: [1000]i64,
}

foo :: proc(alpha: Data, beta: ^Data) {
// Both `alpha` and `beta` reference the same data, but because of
// the size of `alpha`, it is passed by reference internally for speed.
//
// Uncomment the line below to override this behavior.
// alpha := alpha // This will make an explicit copy of the data.
beta.number[5] = 123
fmt.println(alpha.number[5]) // prints 123, unless explicitly copied
}

main :: proc() {
data: Data
foo(data, &data)
}
```

### Multiple results
A procedure in Odin can return any number of results. For example:
```odin
Expand Down