rfcs
rfcs copied to clipboard
Standardise References And Pointers
Standardise the current functionality with pointers and references, and remove ambiguities. Created after a lengthy talk with @spytheman and @medvednikov in #compiler-and-vlib-dev.
Hey, there is one thing that confuses me a bit:
why in the following example is C.external defined with a mut parameter, but called without the mut keyword?
// src
fn C.external(mut &AA)
fn test0(mut v AA) {
C.external(&v)
}
To me this reads that C.external will modify its parameter and that that parameter is a pointer. But if I didn’t see the definition of C.external and only saw the code of test0 then I would assume that C.external does not modify v.
Ofcourse because it is a C function it could do anything with the pointer, but for V readability I would think it’s nice to have to use C.external(mut &v), if I understand your proposal correctly, to indicate that this function indeed modifies v. That is if you define a parameter in a C function as mut.
Hey, there is one thing that confuses me a bit: why in the following example is
C.externaldefined with amutparameter, but called without themutkeyword?// src fn C.external(mut &AA) fn test0(mut v AA) { C.external(&v) }To me this reads that
C.externalwill modify its parameter and that that parameter is a pointer. But if I didn’t see the definition ofC.externaland only saw the code oftest0then I would assume thatC.externaldoes not modifyv.Ofcourse because it is a C function it could do anything with the pointer, but for V readability I would think it’s nice to have to use
C.external(mut &v), if I understand your proposal correctly, to indicate that this function indeed modifiesv. That is if you define a parameter in a C function asmut.
Looks like just missed mut.
Looks like just missed mut.
I did, will update the RFC. I don't believe V supports mut &v anyway yet.