Const pointer semantics
Ziggit
Const pointer semantics
Consider the following function that I want to be able to use for both *const Foo and *Foo arguments: fn getBar(foo: *const Foo) *Bar { //return foo.bar; //errors out return @constCast(foo.bar); } I’m here to argue that the language semantics should be changed so that the @constCast here is not needed, and instead any potential const mismatch be identified at the call sites instead: const foo_v: *Foo = ...; const foo_c: *const Foo = ...; const bar_vv: *Bar = getBar(foo_v); //pass co...
0 comments
No comments yet.