renamed new std/pragmas.nim to std/byaddr.nim (#13844)
* renamed new std/pragmas.nim to std/byaddr.nim * minor code cleanup
This commit is contained in:
parent
68539a2926
commit
d01245e501
3 changed files with 8 additions and 8 deletions
|
|
@ -152,7 +152,7 @@ echo f
|
||||||
- `std/oswalkdir` was buggy, it's now deprecated and reuses `std/os` procs
|
- `std/oswalkdir` was buggy, it's now deprecated and reuses `std/os` procs
|
||||||
- `net.newContext` now performs SSL Certificate checking on Linux and OSX.
|
- `net.newContext` now performs SSL Certificate checking on Linux and OSX.
|
||||||
Define `nimDisableCertificateValidation` to disable it globally.
|
Define `nimDisableCertificateValidation` to disable it globally.
|
||||||
- new syntax for lvalue references: `var b {.byaddr.} = expr` enabled by `import pragmas`
|
- new syntax for lvalue references: `var b {.byaddr.} = expr` enabled by `import std/byaddr`
|
||||||
- new module `std/stackframes`, in particular `setFrameMsg` which enables
|
- new module `std/stackframes`, in particular `setFrameMsg` which enables
|
||||||
custom runtime annotation of stackframes, see #13351 for examples. Turn on/off via
|
custom runtime annotation of stackframes, see #13351 for examples. Turn on/off via
|
||||||
`--stackTraceMsgs:on/off`
|
`--stackTraceMsgs:on/off`
|
||||||
|
|
@ -166,7 +166,7 @@ echo f
|
||||||
of `=destroy` and `copyMem` to move objects efficiently.
|
of `=destroy` and `copyMem` to move objects efficiently.
|
||||||
|
|
||||||
- `var a {.foo.}: MyType = expr` now lowers to `foo(a, MyType, expr)` for non builtin pragmas,
|
- `var a {.foo.}: MyType = expr` now lowers to `foo(a, MyType, expr)` for non builtin pragmas,
|
||||||
enabling things like lvalue references, see `pragmas.byaddr`
|
enabling things like lvalue references, see `byaddr.byaddr`
|
||||||
|
|
||||||
- `macro pragmas` can now be used in type sections.
|
- `macro pragmas` can now be used in type sections.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
# see `semLowerLetVarCustomPragma` for compiler support that enables these
|
# see `semLowerLetVarCustomPragma` for compiler support that enables these
|
||||||
# lowerings
|
# lowerings
|
||||||
|
|
||||||
template byaddr*(lhs, typ, expr) =
|
template byaddr*(lhs, typ, ex) =
|
||||||
## Allows a syntax for lvalue reference, exact analog to
|
## Allows a syntax for lvalue reference, exact analog to
|
||||||
## `auto& a = expr;` in C++
|
## `auto& a = ex;` in C++
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
var s = @[10,11,12]
|
var s = @[10,11,12]
|
||||||
var a {.byaddr.} = s[0]
|
var a {.byaddr.} = s[0]
|
||||||
|
|
@ -12,8 +12,8 @@ template byaddr*(lhs, typ, expr) =
|
||||||
doAssert a is int
|
doAssert a is int
|
||||||
var b {.byaddr.}: int = s[0]
|
var b {.byaddr.}: int = s[0]
|
||||||
doAssert a.addr == b.addr
|
doAssert a.addr == b.addr
|
||||||
when typ is type(nil):
|
when typ is typeof(nil):
|
||||||
let tmp = addr(expr)
|
let tmp = addr(ex)
|
||||||
else:
|
else:
|
||||||
let tmp: ptr typ = addr(expr)
|
let tmp: ptr typ = addr(ex)
|
||||||
template lhs: untyped = tmp[]
|
template lhs: untyped = tmp[]
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import std/pragmas
|
import std/byaddr
|
||||||
|
|
||||||
block:
|
block:
|
||||||
var s = @[10,11,12]
|
var s = @[10,11,12]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue