A suggestion regarding Object#inspect:

I feel that the Object#inspect feature should be unfolded into several
procedures. Currently the code for inspect seems to be mostly in the Array
and Hash classes/files, and the entry point seems to be only the
Object#inspect method. This seems bad for those trying to implement
containers. Also this is bad for when you don't want to show certain
fields in an inspect.

I have several ideas.

First of all, just implementing your own inspect as a simple call to #each
doesn't protect you from loops (or from repeating yourself in cases where
it matters). there are #inspected? / #protect_inspect methods/procs, but
they are not in Ruby, they are only in the internals.

Second, there could be a method in Object called #fields_to_inspect which
would return fields that should be inspected; or there could be a method
#fields_not_to_inspect (a reversed effect).

There is also the case when you only want to see "#<%s:0x%8x>" %
[type,__id__*2] (the default Object#to_s), which is not hiding the field,
but not a full sub-inspect on that field.

There is also the case when you want the ability to distinguish between
"..."'s and actually associate them to other parts of the dump, like
Perl's Data::Dumper does.

More generally, in dumping object contents there's a difference between
what's useful to see as a user, and what's useful for freezing/thawing of
an object (which allows a reasonable way to clone Objects across 
address spaces using eval, for purposes of persistency/IPC.

Also there is a difference between what you wish to see as a user, and
what's generally useful/wanted by users; if this is an important
difference, it might be worthwhile to create a class of Dumper objects
that hold the options for dumping/inspecting. It might also be worthwhile
to use Dumper objects simply to hold the set of visited objects.

_________________________________________________________________
matju | Sevareid's Law: The chief cause of problems is solutions.