[#3747] constants (or class vriable?) — Wakou Aoyama <wakou@...>
青山です。
原です。
青山です。
まつもと ゆきひろです
In message <199812080034.JAA05946@picachu.netlab.co.jp>
立石です。
まつもと ゆきひろです
[#3773] pack("M")/unpack("M") — shugo@... (MAEDA Shugo)
前田です。
[#3794] port NetBSD/ alpha 1.3I — SHIROYAMA Takayuki <psi@...>
[#3826] ruby 1.1d0 released — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
渡辺哲也です。
ふなばです。
笠原です。
前田です。
[#3851] tkutil patch (for 1.1d0) — ttate@...
立石です。
[#3859] missing/setenv.c in 1.1d0 — Inaba Hiroto <inaba@...>
稲葉です。こんなにパッチがあると、みのがされてしまうかも。
[#3862] 1.1d0 new here document — Wakou Aoyama <wakou@...>
青山です。
まつもと ゆきひろです
青山です。
まつもと ゆきひろです
[#3873] (?: ) does not work? — shugo@... (MAEDA Shugo)
前田です。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
前田です。
白山@Stellarです。
[#3881] I want to catch all jump — shugo@... (Shugo Maeda)
前田です。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
[#3894] ruby 1.1d1 released — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
わたなべです.
[#3899] interpreter reinitialization — shugo@... (Shugo Maeda)
前田です。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
[#3962] ruby 1.3(!) released — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
[#3966] [BUG] exception in safe level 4 — shugo@... (Shugo Maeda)
前田です。
[#3997] [BUG] "#{}" while 1 — gotoken@... (GOTO Kentaro)
ごとけんです
まつもと ゆきひろです
[#4002] config.guess — Koji Arai <JCA02266@...>
新井です。
まつもと ゆきひろです
新井です。
まつもと ゆきひろです
新井です。
まつもと ゆきひろです
笠原です。
まつもと ゆきひろです
えぐち@エスアンドイー です。
[#4005] [BUG] ruby 1.3(98/12/24) [i686-linux] at rb_gc_mark() — Ryo HAYASAKA <hayasaka@...>
早坂@会津大学といいます。
In message "[ruby-dev:4005] [BUG] ruby 1.3(98/12/24) [i686-linux] at rb_gc_mark()"
早坂@会津大学です。
[#4015] Integer proper methods — gotoken@... (GOTO Kentaro)
ごとけんです
[#4030] module Precision — gotoken@... (GOTO Kentaro)
ごとけんです
ごとけんです
まつもと ゆきひろです
ごとけんです
けいじゅ@日本ラショナルソフトウェアです.
ごとけんです
まつもと ゆきひろです
まつもと ゆきひろです
ごとけんです
まつもと ゆきひろです
ごとけんです
ごとけんです
けいじゅ@日本ラショナルソフトウェアです.
ごとけんです
まつもと ゆきひろです
まつもと ゆきひろです
まつもと ゆきひろです
ごとけんです
ごとけんです
けいじゅ@日本ラショナルソフトウェアです.
ごとけんです
けいじゅ@日本ラショナルソフトウェアです.
ごとけんです
けいじゅ@日本ラショナルソフトウェアです.
ごとけんです
けいじゅ@日本ラショナルソフトウェアです.
最近あんまり建設的でないわたし.
けいじゅ@日本ラショナルソフトウェアです.
ごとけんです
原です。
[#4032] [Req] make-symbol? — shugo@... (Shugo Maeda)
前田です。
[ruby-dev:3724] Re: multiple assignment, yield and return
原です。
In message "[ruby-dev:3722] multiple assignment, yield and return"
on 98/12/01, Shin-ichro Hara <sinara@blade.nagaokaut.ac.jp> writes:
|スレッドが長くなったのでさし当たって subject を買えました。
ではなくて、「変」えました。(^^;
第0.2回 Ruby Conference で酔っ払いながら喋っていた yield のモデル
のことを一応書いてておきます。
yield(1, 2) を yield([1, 2]) と Array に変換するのも、ある程
度重いのではないでしょうか。そうでもないのかな。
もっと軽いクラス List みたいのをつくって yield(List.new(1, 2))
にしたらどうでしょう。List のメソッドは [], size, to_a ぐらい
しかないわけです。内容的には Array のサブセットでスーパークラス
相当だけど継承関系は独立なものとして。List は Class ではなくて
ユーザーから見えない ruby の内部的な構造としてもいいと思います。
そして、現在の ruby の中で上の List をエミュレートしたものを作っ
てみるとこんな感じです。
class List
def initialize(*x); @list = x; end
def [](x); @list[x]; end
def to_a; @list; end
def +(other); List.new(*(self.to_a+other.to_a)); end
def size; @list.size; end
def inspect; @list.collect{|x| x.inspect}.join(", "); end
end
class Object
def to_l
if is_a? List
self
else
List.new(self)
end
end
end
class Hash1
include Enumerable
def initialize(h); @body = h; end
def each; @body.each{|x,y| yield(List(x,y))}; end
end
class Hash2
include Enumerable
def initialize(h); @body = h; end
def each; @body.each{|x,y| yield([x,y])}; end
end
module Enumerable
def each_with_index(&block)
i = 0
each { |x|
y = x.to_l + i.to_l
block.call(*y)
i += 1
}
end
end
Hash1.new(1=>2).each_with_index {|x| p x} #=> [1,2, 0]
Hash2.new(1=>2).each_with_index {|x| p x} #=> [[1,2], 0]
ここでは List が Array である @list を使っていて混乱しています
が、本来は Array を利用せずに定義されるべきものです。
もう一度言うと yield(Y) は、Y が2つ以上のリストの時、List(Y)
を渡し、1つの時は Y そのものを渡す、とするわけ。
受ける側 |x| は x が List のインスタンスかどうかで、多重代入
かどうか判断できるわけだから、結局 x.is_a? List というフラグ
を渡しているのと同等なんですがね。