borrow dots for distinct types documented

This commit is contained in:
Araq
2014-03-26 08:42:27 +01:00
parent cdb4d83ead
commit 7874c0efcb
3 changed files with 35 additions and 1 deletions

View File

@@ -1569,6 +1569,28 @@ currency. This can be solved with templates_.
defineCurrency(TEuro, int)
The borrow pragma can also be used to annotate the distinct type to allow
certain builtin operations to be lifted:
.. code-block:: nimrod
type
Foo = object
a, b: int
s: string
Bar {.borrow: `.`.} = distinct Foo
var bb: ref Bar
new bb
# field access now valid
bb.a = 90
bb.s = "abc"
Currently only the dot accessor can be borrowed in this way.
Void type
---------

View File

@@ -0,0 +1,13 @@
type
Foo = object
a, b: int
s: string
Bar {.borrow: `.`.} = distinct Foo
var bb: ref Bar
new bb
bb.a = 90
bb.s = "abc"

View File

@@ -4,7 +4,6 @@ version 0.9.4
- fix gensym capture bug
- fix GC issues
Bugs
====