Is #by_ptr really necessary ? #6103
Unanswered
VoidStarCaster
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi !
I have a hard time understanding the necessity of #by_ptr. I get that it is used for const reference parameters, but:
OpaqueStruct :: {} create_opaque :: proc() -> ^OpaqueStruct --- use_opaque :: proc(#by_ptr s: OpaqueStruct) --- main :: proc() { opaque := create_opaque() use_opaque(opaque^) // Will crash or lead to undefined behavior }In the end, it's only use case seems to be for structure that can be created on the stack, to avoid using one '&', which seems really narrow to have it integrated in the language. Especially with all the case where using it can go wrong if you're not cautious enough when writing your bindings.
Should it really be in Odin ? Is there use case I'm not seeing where it is really necessary to have it ?
Beta Was this translation helpful? Give feedback.
All reactions