summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-04-02 11:52:31 +0200
committerGitHub <noreply@github.com>2020-04-02 11:52:31 +0200
commitd01245e501c3d90449383d055da9cb1fe5a24a7f (patch)
treee4f71328ecddd9f96452787db73a0db0e0354a7d
parent68539a2926dd5937e6af640ead200726b46b80b6 (diff)
downloadNim-d01245e501c3d90449383d055da9cb1fe5a24a7f.tar.gz
renamed new std/pragmas.nim to std/byaddr.nim (#13844)
* renamed new std/pragmas.nim to std/byaddr.nim

* minor code cleanup
-rw-r--r--changelog.md4
-rw-r--r--lib/std/byaddr.nim (renamed from lib/std/pragmas.nim)10
-rw-r--r--tests/stdlib/tbyaddr.nim (renamed from tests/stdlib/tpragmas.nim)2
3 files changed, 8 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md
index 2e6da90aa..7dccc20b9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -152,7 +152,7 @@ echo f
 - `std/oswalkdir` was buggy, it's now deprecated and reuses `std/os` procs
 - `net.newContext` now performs SSL Certificate checking on Linux and OSX.
   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
   custom runtime annotation of stackframes, see #13351 for examples. Turn on/off via
   `--stackTraceMsgs:on/off`
@@ -166,7 +166,7 @@ echo f
   of `=destroy` and `copyMem` to move objects efficiently.
 
 - `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.
 
diff --git a/lib/std/pragmas.nim b/lib/std/byaddr.nim
index 5dce04c11..dd7d19da7 100644
--- a/lib/std/pragmas.nim
+++ b/lib/std/byaddr.nim
@@ -1,9 +1,9 @@
 # see `semLowerLetVarCustomPragma` for compiler support that enables these
 # lowerings
 
-template byaddr*(lhs, typ, expr) =
+template byaddr*(lhs, typ, ex) =
   ## Allows a syntax for lvalue reference, exact analog to
-  ## `auto& a = expr;` in C++
+  ## `auto& a = ex;` in C++
   runnableExamples:
     var s = @[10,11,12]
     var a {.byaddr.} = s[0]
@@ -12,8 +12,8 @@ template byaddr*(lhs, typ, expr) =
     doAssert a is int
     var b {.byaddr.}: int = s[0]
     doAssert a.addr == b.addr
-  when typ is type(nil):
-    let tmp = addr(expr)
+  when typ is typeof(nil):
+    let tmp = addr(ex)
   else:
-    let tmp: ptr typ = addr(expr)
+    let tmp: ptr typ = addr(ex)
   template lhs: untyped = tmp[]
diff --git a/tests/stdlib/tpragmas.nim b/tests/stdlib/tbyaddr.nim
index b91d7e547..b485635c7 100644
--- a/tests/stdlib/tpragmas.nim
+++ b/tests/stdlib/tbyaddr.nim
@@ -1,4 +1,4 @@
-import std/pragmas
+import std/byaddr
 
 block:
   var s = @[10,11,12]