Skip to content

Commit f8c1778

Browse files
authored
Merge pull request #2791 from perl6/nativecall-constraint-syntax
nativecall: Add language to address #2684
2 parents 9b2d884 + b596b5b commit f8c1778

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

doc/Language/nativecall.pod6

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,18 @@ say $esponja;
653653
654654
NativeCall also supports native functions that take functions as arguments. One
655655
example of this is using function pointers as callbacks in an event-driven
656-
system. When binding these functions via NativeCall, one need only provide the
656+
system. When binding these functions via NativeCall, one should need only provide the
657657
equivalent signature as L<a constraint on the code parameter|/type/Signature#Constraining_signatures_of_Callables>:
658658
659+
# See below--this syntax does not work on Rakudo currently
660+
use NativeCall;
661+
# void SetCallback(int (*callback)(const char *))
662+
my sub SetCallback(&callback:(Str --> int32)) is native('mylib') { * }
663+
664+
However, in the case of NativeCall, currently Rakudo requires a space between the
665+
function argument and the signature, and the colon of a normal Signature
666+
literal is ommitted, as in:
667+
659668
use NativeCall;
660669
# void SetCallback(int (*callback)(const char *))
661670
my sub SetCallback(&callback (Str --> int32)) is native('mylib') { * }

0 commit comments

Comments
 (0)