I first define a function ADD:
add: func [ a [integer!] b [integer!] ] [a + b]
Then a struct:
s: make struct! [
sadd [ function! ]
] add
But Rebol struct does not support the FUNCTION! datatype. How can I assign a function to a Rebol struct?
Callbacks are an alpha feature of Rebol2. See Carl's article for documentation.
Essentially, if you have a dll such as test-lib.dll where the test function takes two integers and returns them again unchanged
you would write the calling function from Rebol like this
So, this test function takes two integers as parameters and a third parameter which is a Rebol function to be used as a callback. The callback in the routine! is a keyword. The block specification is automatically turned into a structure!
The callback function is written like this which takes the two integers returned by the library call, adds them, and returns them.
And it's then used like this