Created
February 7, 2016 22:28
-
-
Save Araq/03629a7e9e4da243c59f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| VTable = object | |
| methodA: proc (this: MyObject; a, b: int) | |
| methodB: proc (this: MyObject; a, b: string) | |
| OtherObject = object | |
| fieldA: int | |
| fieldB: int | |
| MyObject = object | |
| vtab {.delegate(this).}: ptr VTable | |
| other {.delegate.}: OtherObject | |
| var obj: MyObject | |
| obj.methodA(3, 4) | |
| # is rewritten to: | |
| obj.vtab.methodA(obj, 3, 4) | |
| # also possible: | |
| obj.fieldA | |
| # rewritten to: | |
| obj.other.fieldA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment