diff options
author | Araq <rumpf_a@web.de> | 2019-04-29 13:35:30 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-04-29 13:36:00 +0200 |
commit | 0a84b8fb4d154cb04b1383aa2bf3fcf606b4b8a4 (patch) | |
tree | 5f223c13db101977e9260cc3536019897c62872c /lib/system.nim | |
parent | ddc86d1b4b8104758f95a82534ff945c6853b803 (diff) | |
download | Nim-0a84b8fb4d154cb04b1383aa2bf3fcf606b4b8a4.tar.gz |
added system.unown to make 'owned' sane to use in practice; later on we might change the type inference rules to make it more convenient
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/system.nim b/lib/system.nim index 3d2d9ab48..23868db0f 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1619,7 +1619,7 @@ template `isnot`*(x, y: untyped): untyped = not (x is y) ## assert @[1, 2] isnot enum when defined(nimV2) and not defined(nimscript): - type owned*{.magic: "BuiltinType".}[T] + type owned*{.magic: "BuiltinType".}[T] ## type constructor to mark a ref/ptr or a closure as `owned`. proc new*[T](a: var owned(ref T)) {.magic: "New", noSideEffect.} ## Creates a new object of type ``T`` and returns a safe (traced) @@ -1637,8 +1637,13 @@ when defined(nimV2) and not defined(nimscript): var r: owned(ref t) new(r) return r + + proc unown*[T](x: T): T {.magic: "Unown", noSideEffect.} + ## Use the expression ``x`` ignoring its ownership attribute. + else: template owned*(t: typeDesc): typedesc = t + template unown*(x: typed): typed = x proc new*[T](a: var ref T) {.magic: "New", noSideEffect.} ## Creates a new object of type ``T`` and returns a safe (traced) |