The use of @constCast is generally discouraged, but it's used throughout the library in the Command, Option, and Value types. There two main reasons for this:
- A desire to use
const as a sort of equivalent to val in Kotlin, wherein the data can be made immutable to external users but still be mutated internally.
- A lack of understanding of how
const works. Namely, the fact that it applies to memory directly instead of the data or Type. Because of this, the compiler can make assumptions about const data and even choose to move it to the rodata section of a program.
While the library ostensibly works fine in its current state, this is an item that's worth reviewing for completeness down the line.
The use of
@constCastis generally discouraged, but it's used throughout the library in the Command, Option, and Value types. There two main reasons for this:constas a sort of equivalent tovalin Kotlin, wherein the data can be made immutable to external users but still be mutated internally.constworks. Namely, the fact that it applies to memory directly instead of the data or Type. Because of this, the compiler can make assumptions aboutconstdata and even choose to move it to therodatasection of a program.While the library ostensibly works fine in its current state, this is an item that's worth reviewing for completeness down the line.