Passing read only data to procedures, should I never do it by pointer?

As far as I understand, the odin calling convention will pass things by ref or value depending on which is more efficient. I’ve been using pointers instinctively (because of my time with C) but should I just not bother unless I need to modify the data? Are there any cases where I shouldn’t?

1 Like

So long as you don’t need to modify the data, it is fine to pass it as a value. There is the exception however, when you pass two arguments where one is a pointer, the other is a value, and they both are the same argument at the call site. This can lead to an aliasing bug.

For more information, see: Document pass-by-reference behavior for large arguments by Feoramund · Pull Request #287 · odin-lang/odin-lang.org · GitHub