borrow dots for distinct types documented
This commit is contained in:
parent
cdb4d83ead
commit
7874c0efcb
3 changed files with 35 additions and 1 deletions
|
|
@ -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
|
||||
---------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue