更改RED中的功能签名/正文

时间:2014-12-27 19:07:23

标签: red

在RED中,我们可以使用变量

定义函数
Red [Title: "simple program"]

params: [myvar [integer!]]
body: [print [myvar]]
myfunc: function params body

myfunc 42 ; prints "42"

问题:我怎样才能改变功能签名或身体?

1 个答案:

答案 0 :(得分:1)

您可以使用spec-of和body-of来访问相应的块

M: Function[a "test"][Print a]
Print mold Spec-of :m ; prints [a "test"]
Append Body-of :m 5
M 4 ; prints 4 returns 5

对于更有趣的更改,您可能必须等待实现绑定,才能访问块中的单词。

相关问题