On Wed, Sep 03, 2003 at 11:38:40PM -0700, Alan Chen wrote:
> > Having the block modify the hash is a side effect.  Having the block
> > modify the hash AND return a different value than the one it
> > stores is just plain weird, and if you do it you deserve whatever you
> > get. :)
> 
> Currently thats correct, but this patch makes the hash default block
> logic behave more consistently. 

It already behaves perfectly consistently.  The return value of the
block is what is returned when the key is not present.  That's it,
that's all, nothing more, nothing less.   I completely fail to see the
problem.  It's not an "edge case".  You're looking for extra magic
that is neither called for nor even desirable.

If you want the block to both set and return the hash value, just do it as
the last statement in the block.

There are a myriad of other cases where you can do weird things to
the receiver inside a block and thereby get what appears to be inconsistent
behavior from the outside.  That's a feature, not a flaw; Ruby doesn't
try to protect programmers from themselves invasively.

-Mark