所以我目前正在将一个下降大小的程序从 Rebol 3 迁移到 Red。所述程序依赖于与 C 库 (clang) 的大型绑定。我已经重写了 Red/System 中的绑定部分,并通过包装例程将该代码与 Red 连接。我一直在使用的当前约定是将需要作为参数并由 C 代码返回的指针和 void 指针转换为红色/系统整数并将它们装箱为红色整数。这是相当容易和方便的。
因为我只能访问原始整数!数据而不是实际的结构,我会怀疑我不能再使用上述方法通过参数将指针传回(因为在传递之前正在复制装箱数据)。
那么,是否有推荐的方法来通过参数将指针传回,也就是我们如何通过例程的引用传递?
twiddle: routine [
arg [integer!]
return: [integer!]
] [
arg: 321
test: declare struct! [
dummy [integer!]
]
test/dummy: 456
as integer! test
]
a: 123
b: twiddle a
print a ;If I could pass by reference this would be 321
print b