2006-04-21から1日間の記事一覧

variable in string literal

Ruby では #{} が ${} になる。 i@u ~/test/boo> cat lit_var.boo i = 1 print "i = ${i}" i@u ~/test/boo> booi lit_var.boo i = 1つーわけで Boo Primer はだいたい読んだ。

document

関数の説明を埋めましょう、とのこと。 i@u ~/test/boo> cat document.boo def func(): """hoge""" pass func()ちなみに、 """ の前にスペースを入れるとか、関数宣言の次の行じゃないところに置くとかはエラーになるみたい。それよりこれが。 Dick Brandon:…

duck

普段は型推論つきの静的型付け言語で、 as duck とした部分だけ Ruby とか ObejctiveC みたいな世界に突入する、と。 i@u ~/test/boo> booi duck.boo duck.boo(6,9): BCE0019: Boo.Lang.Compiler.CompilerError: 'Length' is not a member of 'System.Object…

macro

マクロは自分で C# 書いたら定義できるっぽいのが面白そうなんだけど今やるのはちょとめどい。http://boo.codehaus.org/Part+17+-+Macrosprint, assert, using, lock, debug ってのがマクロだそうだ。 print は print 、 debug は printf デバッグ用の物体の…

generator method

Fiber とか coroutine とかいうヤツ。さっきと等価なもの。 i@u ~/test/boo> cat gen_method.boo def gen(): for x in range(5): yield x*x for i in gen(): print i i@u ~/test/boo> booi gen_method.boo 0 1 4 9 16高階?ジェネレータを書いてみる。 Enume…

generator expression

i@u ~/test/boo> cat generator.boo for i in x*x for x in range(5): print i i@u ~/test/boo> booi generator.boo 0 1 4 9 16後置 for とかに見えますが、 x*x for x in range(5) が、 generator オブジェクトで、それを巡回している、と。ふむ。

foreach

コンテナから全部取り出すのは for variable in container で良い。 i@u ~/test/boo> cat foreach.boo for i in (1,2,3): print i for i in [1,2,3]: print i for i in {'a':1, 'b':2, 'c':3}: print i.Key print i.Value i@u ~/test/boo> booi foreach.boo …

reflection

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

BeginInvoke

BeginInvoke でスレッド作って EndInvoke で wait する。 i@u ~/test/boo> cat invoke.boo import System import System.Threading def hello(): print 'hello' Thread.Sleep(500) print 'world' res = hello.BeginInvoke() print res.IsCompleted hello.End…

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