Skip to content

Commit 0cde6db

Browse files
committed
[docs] bind, callmethod
1 parent a7d7169 commit 0cde6db

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/ops.markdown

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,20 @@ Binds `$new_value` to the attribute of name `$attributename` of object `$obj`,
11731173
where the attribute was declared in type `$typeobj`. The notes in the
11741174
`getattr` documentation also apply to `bindattr`.
11751175

1176+
## callmethod
1177+
* `callmethod(Mu $obj, str $methodname, *@pos, *%named)`
1178+
1179+
Uses `findmethod` to locate method `$methodname` on object `$obj`, and `call`
1180+
to invoke the method with positional arguments `*@pos` and named arguments
1181+
`*%named`.
1182+
1183+
Example:
1184+
1185+
class A { method x($a, $b, :$c) { say("$a $b $c") } }
1186+
1187+
nqp::callmethod(A, 'x', '4', '2', c => 'foo');
1188+
# same as: A.x(4, 2, c => 'foo')
1189+
11761190
## can
11771191
* `can(Any $obj, str $method)`
11781192

@@ -1360,6 +1374,14 @@ Gets hold of the argument capture passed to the current block.
13601374
It's valid to implement this exactly the same way as savecapture if there's no performance benefit to be had in a split.
13611375
Used by the multi-dispatcher.
13621376

1377+
# Variable opcodes
1378+
1379+
## bind
1380+
* `bind(Mu $variable, Mu $value)`
1381+
1382+
Binds `$value` to the `$variable`. Dies if `$variable` isn't actually a
1383+
variable. Same as the `:=` operator in NQP.
1384+
13631385
# Miscellaneous Opcodes
13641386

13651387
## debugnoop

0 commit comments

Comments
 (0)