diff options
author | Araq <rumpf_a@web.de> | 2015-09-06 02:29:30 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-09-06 02:31:28 +0200 |
commit | dc047931bbde432512053c91d0cb9b8a230a7574 (patch) | |
tree | 7a56044ed8db0c741cd5777bb192c7e155617c8e /doc/manual | |
parent | d2e4d6ad8235e96191faae376c134e224fafdc11 (diff) | |
download | Nim-dc047931bbde432512053c91d0cb9b8a230a7574.tar.gz |
fixes #2590; methods now require a .base annotation
Diffstat (limited to 'doc/manual')
-rw-r--r-- | doc/manual/procs.txt | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/doc/manual/procs.txt b/doc/manual/procs.txt index bd86e4651..9d00b7e3c 100644 --- a/doc/manual/procs.txt +++ b/doc/manual/procs.txt @@ -385,7 +385,7 @@ dispatch. PlusExpr = ref object of Expression a, b: Expression - method eval(e: Expression): int = + method eval(e: Expression): int {.base.} = # override this base method quit "to override!" @@ -410,6 +410,11 @@ In the example the constructors ``newLit`` and ``newPlus`` are procs because they should use static binding, but ``eval`` is a method because it requires dynamic binding. +As can be seen in the example, base methods have to be annotated with +the `base`:idx: pragma. The ``base`` pragma also acts as a reminder for the +programmer that a base method ``m`` is used as the foundation to determine all +the effects that a call to ``m`` might cause. + In a multi-method all parameters that have an object type are used for the dispatching: @@ -419,7 +424,7 @@ dispatching: Unit = ref object of Thing x: int - method collide(a, b: Thing) {.inline.} = + method collide(a, b: Thing) {.base, inline.} = quit "to override!" method collide(a: Thing, b: Unit) {.inline.} = |