system.reset is no longer magic (#12937)
It has now means setting x to default for new and old runtime alike
This commit is contained in:
parent
e041c184d2
commit
10bd7d8fa0
1 changed files with 9 additions and 11 deletions
|
|
@ -264,17 +264,6 @@ when not defined(gcDestructors):
|
||||||
## **Note**: The `finalizer` refers to the type `T`, not to the object!
|
## **Note**: The `finalizer` refers to the type `T`, not to the object!
|
||||||
## This means that for each object of type `T` the finalizer will be called!
|
## This means that for each object of type `T` the finalizer will be called!
|
||||||
|
|
||||||
when defined(nimV2):
|
|
||||||
proc reset*[T](obj: var T) {.magic: "Destroy", noSideEffect.}
|
|
||||||
## Old runtime target: Resets an object `obj` to its initial (binary zero) value.
|
|
||||||
##
|
|
||||||
## New runtime target: An alias for `=destroy`.
|
|
||||||
else:
|
|
||||||
proc reset*[T](obj: var T) {.magic: "Reset", noSideEffect.}
|
|
||||||
## Old runtime target: Resets an object `obj` to its initial (binary zero) value.
|
|
||||||
##
|
|
||||||
## New runtime target: An alias for `=destroy`.
|
|
||||||
|
|
||||||
proc wasMoved*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
|
proc wasMoved*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
|
||||||
## Resets an object `obj` to its initial (binary zero) value to signify
|
## Resets an object `obj` to its initial (binary zero) value to signify
|
||||||
## it was "moved" and to signify its destructor should do nothing and
|
## it was "moved" and to signify its destructor should do nothing and
|
||||||
|
|
@ -1825,6 +1814,15 @@ when defined(nimHasDefault):
|
||||||
proc default*(T: typedesc): T {.magic: "Default", noSideEffect.}
|
proc default*(T: typedesc): T {.magic: "Default", noSideEffect.}
|
||||||
## returns the default value of the type ``T``.
|
## returns the default value of the type ``T``.
|
||||||
|
|
||||||
|
proc reset*[T](obj: var T) {.noSideEffect.} =
|
||||||
|
## Resets an object `obj` to its default value.
|
||||||
|
obj = default(typeof(obj))
|
||||||
|
else:
|
||||||
|
when defined(nimV2):
|
||||||
|
proc reset*[T](obj: var T) {.magic: "Destroy", noSideEffect.}
|
||||||
|
else:
|
||||||
|
proc reset*[T](obj: var T) {.magic: "Reset", noSideEffect.}
|
||||||
|
|
||||||
proc setLen*[T](s: var seq[T], newlen: Natural) {.
|
proc setLen*[T](s: var seq[T], newlen: Natural) {.
|
||||||
magic: "SetLengthSeq", noSideEffect.}
|
magic: "SetLengthSeq", noSideEffect.}
|
||||||
## Sets the length of seq `s` to `newlen`. ``T`` may be any sequence type.
|
## Sets the length of seq `s` to `newlen`. ``T`` may be any sequence type.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue