We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let a {.rom.} = constExpr
WIP proposal as alternative to the buggy let a = constExpr.unsafeAddr refs nim-lang#16794
let a = constExpr.unsafeAddr
note: const with ref types should be merged as-is (refs nim-lang#15528) and doesn't interfere with this proposal
nim-lang/RFCs#257 can be fixed in a way that doesn't break the type system as follows:
let b {.rom.} = [1,2] # b ends in ROM memory func fn(): int = b[0] # no side effect thanks to {.rom.} let b2 = b[0].addr const b3 = b
IMO semantics for 1a is better than 1b, because semantically, b{.rom.} is closer to a let (gets generated in backend, has backend layout etc);
const a = [1,2] const b {.addressable.} = [1,2] func fn(): int = b[0] # no side effect thanks to {.rom.} let b2 = b[0].addr const b3 = b
const a = [1,2] let b {.immutable.} = [1,2] func fn(): int = b[0] # no side effect thanks to {.rom.} let b2 = b[0].addr
note: that variant would also allow RT values inside definition of b eg:
var x = 2 let b {.immutable.} = [1, x]
but this would preclude using b at CT in subsequent expressions
can be implemented using sections, refs https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_cmf1493390581125.htm
int x1 = 5; // Goes in .data section (default) int y1; // Goes in .bss section (default) const int z1 = 42; // Goes in .rodata section (default) char *s1 = "abc1"; // s1 goes in .data section (default). String "abc1" goes in .conststring section. #pragma clang section bss="myBSS" data="myData" rodata="myRodata" int x2 = 5; // Goes in myData section. int y2; // Goes in myBss section. const int z2 = 42; // Goes in myRodata section. char *s2 = "abc2"; // s2 goes in myData section. String "abc2" goes in .conststring section.
use this instead of the more hacky prepareStrMutation (nim-lang#17213) (refs nim-lang#17173)
prepareStrMutation
The text was updated successfully, but these errors were encountered:
const a {.addressable.} = constExpr
rom
Sorry, something went wrong.
let a = someConst.unsafeAddr
No branches or pull requests
WIP proposal as alternative to the buggy
let a = constExpr.unsafeAddr
refs nim-lang#16794note: const with ref types should be merged as-is (refs nim-lang#15528) and doesn't interfere with this proposal
nim-lang/RFCs#257 can be fixed in a way that doesn't break the type system as follows:
proposal 1a (mutually exclusive with 1b)
IMO semantics for 1a is better than 1b, because semantically, b{.rom.} is closer to a let (gets generated in backend, has backend layout etc);
proposal 1b
proposal 2 (can be done independently of 1a or 1b)
note: that variant would also allow RT values inside definition of b eg:
but this would preclude using b at CT in subsequent expressions
notes
can be implemented using sections, refs https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_cmf1493390581125.htm
note
use this instead of the more hacky
prepareStrMutation
(nim-lang#17213) (refs nim-lang#17173)The text was updated successfully, but these errors were encountered: