From: keiju@... (=?ISO-2022-JP?B?GyRCQFBETTc9PHkbKEI=?= ) Date: 1997-08-26T16:08:51+09:00 Subject: [ruby-dev:264] Re: [BUG] MLF けいじゅ@日本ラショナルです. In [ruby-dev :00263 ] the message: "[ruby-dev:263] Re: [BUG] MLF ", on Aug/26 12:54(JST) matz@netlab.co.jp (Yukihiro Matsumoto) writes: >まつもと ゆきひろです >この件に対処するものではなかったですからねえ. >パッチを当てた後に更にこのパッチを当てて下さい. 今度はうまくいきました. けど... さらに困難な問題にぶち当たりました(;_; 多分, 動的クラスの名称決定アルゴリズムに問題があるんだと思うのですが, どういう時に発生するのか, 簡単なプログラムで再現しようと思ったのですが, 全然できません(;_; というわけで, 元プログラムを送りますので, 原因をつかんで下さい. e2mmap.rbを実行すると(ここ1)で無限ループに入ります. (ここ1)をコメント アウトして(ここ2)まで行くようにすると, クラス名が無事表示されるように なります. このモジュールは Exception2MessageMapperに自分自身をextendしているので このあたりが問題になっているのかも知れません... クラス階層はloopしてい ないと思うのですが.... -- e2mmap.rb if VERSION < "1.1" require "e2mmap1.0.rb" else module Exception2MessageMapper RCS_ID='-$Header: /home/keiju/var/src/var.lib/ruby/RCS/e2mmap.rb,v 1.4 1997/08/18 07:12:12 keiju Exp keiju $-' E2MM = Exception2MessageMapper def E2MM.extend_object(cl) super cl.bind(self) end def E2MM.extend_to(b) c = eval("self", b) c.extend(self) end def bind(cl) begin map = const_get(:E2MM_ErrorMSG, all).dup rescue NameError map = Hash.new end const_set(:E2MM_ErrorMSG, map) self.module_eval %q^ def fail!(*rest) super end # fail(err, *rest) # err: 例外 # rest: メッセージに渡すパラメータ # def fail(err, *rest) if form = E2MM_ErrorMSG[err] $! = err.new(sprintf(form, *rest)) $@ = caller(0) $@.shift super() else E2MM.fail E2MM::ErrNotRegisteredException, err.to_s end end public :fail # def_exception(c, m) # c: exception # m: message_form # 例外cのメッセージをmとする. # def def_e2message(c, m) E2MM_ErrorMSG[c] = m end # def_exception(c, m) # n: exception_name # m: message_form # s: 例外スーパークラス(デフォルト: Exception) # 例外名``c''をもつ例外を定義し, そのメッセージをmとする. # #def def_exception(n, m) def def_exception(n, m, s = Exception) print "in\n" n = n.id2name if n.kind_of?(Fixnum) print "in2\n" e = Class.new(s) print s.inspect, "\n" print e.inspect, "\n" #<----------------(ここ1) const_set(n, e) print e.inspect, "\n" #<----------------(ここ2) E2MM_ErrorMSG[e] = m print E2MM_ErrorMSG.inspect end ^ end extend Exception2MessageMapper def_exception(:ErrNotClassOrModule, "Not Class or Module") def_exception(:ErrNotRegisteredException, "not registerd exception(%s)") end end __ ..........................................石塚 圭樹@日本ラショナル... ----------------------------------->> e-mail: keiju@bc.mbn.or.jp <<---