From: "Chr. Rippel" Date: 2002-01-30T20:43:49+09:00 Subject: Re: Proc hash bug? wrote in .... > > Current implementation converts Proc <-> Block for each time, > > so that &var Proc is generated each time. This might change > > in the future, but I cannot ensure the hash (or identity) equality. > > This breaks POLS for me in a big way (but maybe not for you). I expect > the block to remain the same whether I pass it in through the arguments > as an object, or whether I use & to associate it directly with the > method call. I can see why, implementation-wise, it might be easier to > make them different, but I can't see from a user's perspective how the > behavior makes sense. I guess by now I expect my POLS to be broken, in particular when comes to issue of hashing. .... > to go with a less attractive alternative, but I guess I'm looking either > for more of an explanation or a fix. I'd submit an RCR for it if you > think it's worthwhile. If it was me I would be trying to avoid envoking the proc <-> conversion. Of course there is some sort of fix - which is likely very dangerous (you probably can improve on it though) --- P = proc {P} def bla(a, & b) hsh = { a => 3} p hsh[b] end class Proc def hash inspect.sub(/^(#)$/){''}.to_i(16) end def eql?(other) unless other.instance_of? (type) false else hash == other.hash end end end bla (P,&P) # => 3 ---- /Christoph