[#34722] cgi.rb の form の挙動 — FUJIOKA Takeyuki <fujioka@...>
藤岡です。
18 messages
2002/04/02
[#34754] 続: cgi.rb の form の挙動
— FUJIOKA Takeyuki <fujioka@...>
2002/04/03
藤岡です。
[#34755] Re: 続: cgi.rb の form の挙動
— Wakou Aoyama <wakou@...>
2002/04/03
青山です。
[#34758] Re: 続: cgi.rb の form の挙動
— FUJIOKA Takeyuki <fujioka@...>
2002/04/03
藤岡です。
[#34759] Re: 続: cgi.rb の form の挙動
— Wakou Aoyama <wakou@...>
2002/04/03
青山です。
[#34769] Re: 続: cgi.rb の form の挙動
— FUJIOKA Takeyuki <fujioka@...>
2002/04/04
藤岡です。
[#34724] 「たのしい Ruby 」 — Shin-ichiro HARA <sinara@...>
原(信)です。
18 messages
2002/04/02
[#34728] Re: 「たのしい Ruby 」
— matz@... (Yukihiro Matsumoto)
2002/04/02
まつもと ゆきひろです
[#34746] Re: 「たのしい Ruby 」
— TAKAHASHI Masayoshi <maki@...>
2002/04/02
高橋征義です。
[#34752] Re: 「たのしい Ruby 」
— Shin-ichiro HARA <sinara@...>
2002/04/03
原(信)です。
[#34763] Re: 「たのしい Ruby 」
— TAKAHASHI Masayoshi <maki@...>
2002/04/04
高橋征義です。
[#34730] RubyUnit: I want to test a message of an exception with assert_exception(){}. — NISHIMATSU Takeshi <t-nissie@...>
西松と申します.
7 messages
2002/04/02
[#34732] Re: RubyUnit: I want to test a message of an exception with assert_exception(){}.
— nobu.nakada@...
2002/04/02
なかだです。
[#34735] Re: RubyUnit: I want to test a message of an exception with assert_exception(){}.
— Koji Arai <JCA02266@...>
2002/04/02
新井です。
[#34771] 用語集 super の問題 — Kazuhiro Yoshida <moriq.kazuhiro@...>
もりきゅうです。
7 messages
2002/04/04
[#34820] libplot - Bus Error on Solaris 8 — KATAYAMA Toshiaki <katayama@...>
Solaris 8 の上で ruby-libplot-0.0.5 + plotutils-2.4.1 を使いたいと
4 messages
2002/04/04
[#34835] module_function([name ... ]) — Kazuhiro Yoshida <moriq.kazuhiro@...>
もりきゅうです。
10 messages
2002/04/06
[#34842] [ann] Web 家計簿(β版)リリース — 堀川 久 <vzw00011@...>
こんにちは。
18 messages
2002/04/07
[#34869] Re: [ann] Web 家計簿(β版)リリース
— Nobuhide Kanagawa <nobuhide@...>
2002/04/11
こんばんわ!
[#34870] Re: [ann] Web 家計簿(β版)リリース
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/04/11
金光です。どもっ。
[#34885] creating a scope / anonymous module — Takaaki Tateishi <ttate@...>
立石です.
38 messages
2002/04/13
[#34888] Re: creating a scope / anonymous module
— Koji Arai <JCA02266@...>
2002/04/13
新井です。
[#34891] Re: creating a scope / anonymous module
— nobu.nakada@...
2002/04/14
なかだです。
[#34892] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/14
At Sun, 14 Apr 2002 18:00:12 +0900,
[#34894] Re: creating a scope / anonymous module
— nobu.nakada@...
2002/04/14
なかだです。
[#34896] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/14
At Sun, 14 Apr 2002 21:08:47 +0900,
[#34899] Re: creating a scope / anonymous module
— matz@... (Yukihiro Matsumoto)
2002/04/15
まつもと ゆきひろです
[#34901] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/15
At Mon, 15 Apr 2002 09:51:05 +0900,
[#34902] Re: creating a scope / anonymous module
— matz@... (Yukihiro Matsumoto)
2002/04/15
まつもと ゆきひろです
[#34903] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/15
At Mon, 15 Apr 2002 13:53:53 +0900,
[#34904] Re: creating a scope / anonymous module
— matz@... (Yukihiro Matsumoto)
2002/04/15
まつもと ゆきひろです
[#34910] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/15
At Mon, 15 Apr 2002 15:07:57 +0900,
[#34911] Re: creating a scope / anonymous module
— matz@... (Yukihiro Matsumoto)
2002/04/15
まつもと ゆきひろです
[#34913] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/15
At Mon, 15 Apr 2002 17:47:00 +0900,
[#34923] Re: creating a scope / anonymous module
— Takaaki Tateishi <ttate@...>
2002/04/16
立石です.
[#34924] Re: creating a scope / anonymous module
— matz@... (Yukihiro Matsumoto)
2002/04/16
まつもと ゆきひろです
[#34897] icc でコンパイルできない — rubikitch <rubikitch@...>
るびきちです。
7 messages
2002/04/14
[#34921] ruby-1.6.7 got SIGILL on Debian/sparc (with patch) — ryu1 <ryu1@...>
はじめまして。
6 messages
2002/04/16
[#34943] Thread by callcc — Shin-ichiro HARA <sinara@...>
原です。
9 messages
2002/04/18
[#34958] windows 版 ruby でシステムコマンドが動かない — "jazzski _comp" <jazzski_comp@...>
はじめてrubyを使うのですが、windows版(cygwin版1.6.1)で下記のように
12 messages
2002/04/23
[ruby-list:34956] Re: Thread by callcc
From:
sinara@...
Date:
2002-04-22 13:08:18 UTC
List:
ruby-list #34956
原です。
In message "[ruby-list:34952] Re: Thread by callcc"
on 02/04/21, Tanaka Akira <akr@m17n.org> writes:
>だとしたら、むしろスレッドの亜種としてコルーチンのサポートを入れるとい
>う手もあるのでは?
>
>と、思ったので、試してみました。
なるほど、Thread でもできるとは思っていたのですが、面白いですね。
Coroutine は、2つのスレッドでのピンポン方式ですね。
>--- sync-each.rb ---
>require 'coroutine'
SyncEach はピンポンでする方法もあるのか、、、この方式の CoThread
版を書いておきます。
---^ sync-each2.rb
require "co-thread-queue"
class SyncEach
include Enumerable
def initialize(*es)
@size = es.first.size
@cs = es.map { |e|
(ct = CoThread.new).fork do
e.each do |x|
ct.pass(x)
end
end
}
end
def each
@size.times do
yield @cs.map{ |c| c.pass }
end
end
end
if $0 == __FILE__
foo = SyncEach.new(0..3, 10..13, 20..23)
foo.each do |a|
p a
end
end
---$ sync-each2.rb
>行数を比較してみるとわかりますが、ほとんど同じです。
そうですね。まねして Thread による CoThread を作ってみました。
やはり、ほとんど同じですね。
---^ co-thread-queue.rb
require 'thread'
class CoThread
def queue
Thread.current[:queue] ||= SizedQueue.new(1)
end
def initialize
@queues = []
end
def fork
Thread.start do
@queues.push(queue)
x = queue.deq
r = yield(x)
@queues.shift.enq(r)
end
self
end
def pass(x = nil)
@queues.push(queue)
@queues.shift.enq(x)
queue.deq
end
end
if $0 == __FILE__
ct = CoThread.new
ct.fork do |x|
puts x
puts 2
puts ct.pass(2.5)
puts 5
5.5
end
ct.fork do |x|
puts x
puts 3
puts ct.pass(3.5)
puts 6
6.5
end
puts 1
puts ct.pass(1.5)
puts 4
puts ct.pass(4.5)
puts 7
end
---$ co-thread-queue.rb
これは、ほぼ co-thread.rb と互換で、YaProc, SyncEach, Generator,
CoQueue すべて動作します。
、、、ということは Thread があれば、Proc はいらないのか、、、
>というわけで、
>
>> それぞれ、Thread を使うとかなり気を使わなければならないところが、
>> ずいぶん素直に書けていると思います。
>
>という主張は、やはり、単にロックを気にしなくていいというところに起因す
>るのであろうという結論に至りました。
いえ、それはそうなんですが、そこが大事ではないでしょうか。「ずいぶん
素直に書けている」とは、例えば thread.rb などのライブラリのことを言っ
たつもりでした。Mutex とか Queue とか SizedQueue とかの実装はかなり
むずかしく、ほとんど「職人の技」です。それに比べれば callcc の扱いは、
順番にのみ注意すればよく、Thread があらゆるタイミングの組み合わせを
考えなれければならないのに比べ、(ライブラリの)プログラマにとっては
大分負担が軽いと思います。
>とくにライブラリは厄介で、こういうのを安全に使うには、全ての(あるいは
>少なくとも大部分の)ライブラリが、常にクライアントのコードを実行したら
>そこで継続を保存されて、何回も再入してくるという可能性を考慮して書かな
>いといけません。これはライブラリの作者にとって負荷が高すぎ、しかも、そ
>れに対して用途が少な過ぎる、というのが知合い(g新部さん)の callcc 有害
>論です。
私も、有害論者だけど面白がり、というところです。それでも限定した使
い方、例えば co-thread.rb による利用に限れば、そんなに問題ないので
は。もちろん callcc がなくても書けるものはなしで書くべきで、そのた
めのイテレータや Proc だったりするわけでから。
しかし、Thread と Continuation、どちらでも書けるなら前者でなければ
ならない、という理由もない気もします。