# Red语法
目前还没有Red
语法的详细文档,但是因为Red
跟Rebol
语法基本相似,所以可以参考Rebol
的语法。
# Red's Hello World!
Red []
print "Hello World!"
print "世界你好!"
相比Rebol
,Red
是天生支持Unicode
的,对于非英语系来说,这是个福音。恋上Red
,支持Unicode
是一个原因,另外一个就是这家伙的GUI
要做成naive的。以前鼓捣了一下Rebol
的View
也是蛮有意思的,就是界面有点Ugly
。
# Red内部使用Red/System代码
有两种方法可以实现Red
调用Red/System
# 内嵌方法#system-global
这种方法类似在C中插入ASM代码
`#system-global` [
print "Here you can use Red/System syntax"
]
# routine方法
上面的方面只是插入了Red/System
代码块,如果需要调用函数,需要使用routine
方法。
increment: routine [
n [integer!]
return: [integer!]
][
n + 1
]
在routine
中可以方便使用Red/System
语法:
Red[
Title: "hello"
Author: "jocko"
File: %hello-2.red
]
; --- lib imports -----
#system[
#import [
"user32.dll" stdcall [
MessageBox: "MessageBoxA" [
handle [integer!]
text [c-string!]
title [c-string!]
type [integer!]
return: [integer!]
]
]
]
]
; note the conversion from string to c-string :
; as c-string! string/rs-head txt
alert: routine [
txt [string!]
return: [integer!]][
MessageBox 0 as c-string! string/rs-head txt "alert" 48
]
confirm: routine [
txt [string!]
return: [integer!]
/local rep [integer!]][
rep: MessageBox 0 as c-string! string/rs-head txt "confirm" 4
if rep = 6 [rep: 1] ; otherwise rep = 7
rep
]
rep: 0
until [
alert "hello, red world !"
rep: confirm "quit ?"
rep = 1
]
# Red Roadmap
- 0.5.1 New console
- 0.5.2 New Android toolchain
- 0.5.3 Redbin
- 0.6.0 GUI support
- 0.7.0 I/O support
- 0.8.0 Cuncurrency support
- 0.8.5 Modules
- 0.9.0 Garbage collector (first beta)
- 1.0.0 First stable release
到0.7.0版本发布时,就可以比较happy的使用了。