reflection

なんか言語知ってる子が新しい言語環境を覚える時はさっさとリフレクションを修得すべき。 Boo というより C#ドメインなんだろうけど。というわけでさっきの res (型は IAsyncResult とからしい) のメソッド一覧。

i@u ~/test/boo> cat reflection.boo
def func():
    pass
res = func.BeginInvoke()
for i in res.GetType().GetMembers():
    print i
i@u ~/test/boo> booi reflection.boo
System.Object get_AsyncState()
System.Threading.WaitHandle get_AsyncWaitHandle()
Boolean get_CompletedSynchronously()
Boolean get_IsCompleted()
Boolean get_EndInvokeCalled()
Void set_EndInvokeCalled(Boolean)
System.Object get_AsyncDelegate()
IMessageSink get_NextSink()
IMessageCtrl AsyncProcessMessage(IMessage, IMessageSink)
IMessage GetReplyMessage()
Void SetMessageCtrl(IMessageCtrl)
IMessage SyncProcessMessage(IMessage)
Boolean Equals(System.Object)
Int32 GetHashCode()
System.Type GetType()
System.String ToString()
System.Object AsyncState
System.Threading.WaitHandle AsyncWaitHandle
System.Boolean CompletedSynchronously
System.Boolean IsCompleted
System.Boolean EndInvokeCalled
System.Object AsyncDelegate
System.Runtime.Remoting.Messaging.IMessageSink NextSink

ついでにコンテナをなめる処理が出てきたので次に続く。

class

コンストラクタ呼出しの記法が Class("hoge") で、 new がいらないのがいい。このへんでも書いた

@u ~/test/boo> cat class.boo
class C:
        [Property(Id)]
        _id as int

        def constructor(i):
                _id = i

c = C(1)
print c.Id
c.Id = 2
print c.Id

i@u ~/test/boo> booi class.boo
1
2

継承とかはだいたい普通。

あと struct があるのも素敵。 enum も。まぁ要は .Net ということなのかな。

とりあえず primer の 14 まで見た。このへんからが面白そう。

containers

i@u ~/test/boo> cat container.boo
l = [1,2,3]
a = (1,2,3)
h = {'a':1,'b':2,'c':3}
print l
print a
print h
print l[:2]
print a[:2]
//print h[:2]

i@u ~/test/boo> booi container.boo
[1, 2, 3]
System.Int32[]
Boo.Lang.Hash
[1, 2]
System.Int32[]

配列とリストがわけてあるのは非常に良いですなあ。あと Boo primer とはなんか配列の print が違う気がするけど気にしない。

compiling...

nant-0.85-rc3 を make 。途中で止まったが bootstrap とやらができれば十分ぽいので気にしない。

i@u ~/bin> cat nant
#!/bin/sh
exec mono ~/src/nant-0.85-rc3/bootstrap/NAnt.exe $@

boo-0.7.5.2013 を nant 。 default.build をいじって optimize を true に。んで nant すると途中で止まったけど Boo.Lang.dll はできたから気にしない。

sdldotnet-4.0.3-1 を nant buildrelease 。なんかこれはちゃんとできたぽい。 SdlDotNet.dll と Tao.Sdl.dll ができればオッケイ。 Tao.Sdl.dll の方が単純な SDL ラッパ。 API 覚えるのめんどいからこっちだけでいいかも。

あと SDL.dll とか SDL_image.dll が無いって怒られたから適当に /usr/local/lib/libSDL.so とかを libSDL.dll.so にシンボリックリンクでゴマかす。

loop

あと for と while と continue と break があるらしい。そういう普通なのはいいや。

pass ってのが異様。

i@u ~/test/boo> cat pass.boo
while false:
print "end"
i@u ~/test/boo> booi pass.boo
pass.boo(2,1): BCE0044: Boo.Lang.Compiler.CompilerError: 'expecting "INDENT", found '<EOS>''. ---> pass.boo:2:1: expecting "INDENT", found '<EOS>'--- End of inner exception stack trace ---


i@u ~/test/boo> cat pass.boo
while false:
    pass
print "end"
i@u ~/test/boo> booi pass.boo
end

要は nop だ。カラの文が無いとかまぁそんなこんなな話か。

なにかあれば下記メールアドレスへ。
shinichiro.hamaji _at_ gmail.com
shinichiro.h