Ioという言語を触ってみる1

去年買った、「7つの言語、7つの世界」を見て、Ioという言語を触ってみることにした。
なんだか面白そうだ。というか、読んだだけでは分からなかったので。
公式サイト
http://www.iolanguage.com/
ドキュメント
http://www.iolanguage.com/docs/
和訳を発見した、感謝!(若干古い部分がある点に注意)
Ioプログラミングガイド
http://xole.net/docs/IoGuide_ja.html
Io チュートリアル
http://xole.net/docs/IoTutorial_ja.html
Io リファレンス マニュアル
http://xole.net/docs/IoReference_ja.html


驚いたのは、ifも、forもあるにはあるが、キーワードではない、という。
それどころか、キーワード(予約語)は「ない」らしい。なんと、思い切りの良い。。
擬似BNFがプログラミングガイドに載っているが5行である。こんな言語初めて見たかも。
で、今日までにわかったことを書いてみた。
# 引数を受け取る

e_c_e_t$cat getargs.io 
#!/usr/vin/env io
System args foreach(k, v, write("'", v, "'\n"))

e_c_e_t$io getargs.io  a b c d e f
'getargs.io'
'a'
'b'
'c'
'd'
'e'
'f'

#スクリプトのあるディレクトリを取得する

e_c_e_t$cat getpwd.io 
#!/usr/bin/env io
System launchPath println


e_c_e_t$io getpwd.io 
/Users/e_c_e_t/src/iolang/iosrc

#アキュムレータ(0+1, 0+1+2, 0+1+2+3を表示)

e_c_e_t$cat accumelator.io 
#!/usr/bin/env io
Accumulator := Object clone
Accumulator sum := 0
Accumulator add := method(amount,
    sum = sum + amount
)

Accumulator show := method(
    sum println
)

a := Accumulator clone
a show
a add(1)
a show
a add(2)
a show
a add(3)
a show

e_c_e_t$io accumelator.io 
0
1
3
6
e_c_e_t$

本のサンプルに手をつける予定だったんだが。遊んでしまった。
恥ずかしながら、prototypeの意味が初めてわかったような感じがしました。


ここまで書いて、物凄い資料を発見した。感謝してこれで勉強させてもらおう。
http://brace.client.jp/DOC/iotuto.html