more arc features (#13098)

* config update
* ARC now supports 'repr' and 'new' with finalizers is supported
This commit is contained in:
Andreas Rumpf 2020-01-10 23:17:33 +01:00 • committed by GitHub
commit 767592a3c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 252 additions and 13 deletions

View file

@ -0,0 +1,25 @@
discard """
cmd: "nim c --gc:arc $file"
output: '''Foo(field: "Dick Laurent", k: ka, x: 0.0)
Dick Laurent is dead'''
"""
type
Kind = enum
ka, kb
Foo = ref object
field: string
case k: Kind
of ka: x: float
of kb: discard
#var x = Foo(field: "lovely")
proc finalizer(x: Foo) =
echo x.field, " is dead"
var x: Foo
new(x, finalizer)
x.field = "Dick Laurent"
# reference to a great movie. If you haven't seen it, highly recommended.
echo repr x