プロトタイプとは
自分用和訳したので、ココにメモ。
プロトタイプ
In Io, everything is an object (including the locals storage of a block and the namespace itself) and all actions are messages (including assignment). Objects are composed of a list of key/value pairs called slots, and an internal list of objects from which it inherits called protos. A slot's key is a symbol (a unique immutable sequence) and its value can be any type of object. clone and init New objects are made by cloning existing ones. A clone is an empty object that has the parent in its list of protos. A new instance's init slot will be activated which gives the object a chance to initialize itself. Like NewtonScript[3], slots in Io are create-on-write.
me := Person cloneTo add an instance variable or method, simply set it:
myDog name := "rover" myDog sit := method("I'm sitting\n" print)When an object is cloned, its "init" slot will be called if it has one.
Io プログラミングガイド - オブジェクト - プロトタイプ
プロトタイプ
Ioでは、(ローカルのブロック記憶領域や名前空間それ自体を含む)全てがオブジェクトであり、(値の代入を含む)全ての振舞いはメッセージです。オブジェクトはスロットというキーと値のペアのリストと、protosという継承したオブジェクトの内部リストから出来ています。あるスロットのキーはシンボル(つまり、ユニークな不変の文字列?)であり、あらゆる型のオブジェクトをその値に取ります。新たなオブジェクトのcloneとinitで、既にあるオブジェクトのクローンを作成します。あるクローンは、protosのリストにその親を持つ空のオブジェクトです。新しいインスタンスのinitスロットは有効になり、そのオブジェクトを初期化するために使われます。NewtonScriptのように、Ioのスロットはcreate-on-write?です。
me := Person cloneインスタンスに変数やメソッドを追加するには、単純にセットします:
myDog name := "rover" myDog sit := method("I'm sitting\n" print)あるオブジェクトのクローンが作成されると、そのinitスロットがあれば、それが呼ばれます。
和訳における「a = ある, the = その」メソッドは、大体正しい。