Skip to content

Commit

Permalink
update references
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Sep 10, 2024
1 parent b41ae49 commit 373aaf4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/memory/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ fn main() {

This is the result of the compiler trying to make sure things are safe. It always asks to reference a variable to keep a good watch on your reference and make sure it's safe. This is an effort to guarantee that your reference will never be dangling because the scope of your variable is traceable.

An expression which is pointed to always must be variable based. For example, variables, structure (stored in variable) field or arrays. Slices are not supported because they might deallocate internal buffer to grow, so references are not safe for slices. But arrays always supported because they are guaranteed to be fixed size at runtime always.

## Concurrency

Concurrency imposes a number of process-intensive conditions that are difficult to trace at compile time and further increase compile times. Using references in a concurrent call means that the scope of the variable cannot be properly traced. Therefore, concurrent calls do not support functions with reference parameters.
Expand Down

0 comments on commit 373aaf4

Please sign in to comment.