To delegate high-performance code snippets to Red/System, we need a way to call into Red/System from Red. Suppose we want to call our Red/System fact function from a Red script. This is done as follows:
;-- see Chapter10/use-fact.red:#system-global [#include %fact.reds] ; (1)red-fact: routine [ ; (2) n [integer!] ; (3) return: [integer!]][ fact n ; function from fact.reds ; (4)]print red-fact 9 ;== 362880 ; (5)
In line (1), the Red/System script is included as usual Red scripts, but it must be prefixed by #system-global, a directive. This line also executes the Red/System script, so be sure to remove or comment out any executable code from it. As indicated in line (2), a Red function that calls ...