On Tue, Mar 04, 2008 at 06:41:59AM +0900, Akinori MUSHA wrote:
> You need to give a convincing example or two out of "a lot" to show
> how it reasonably helps you.  What's wrong with a static variable
> instead?

1. In Rice (http://rice.rubyforge.org) we attach data to a function so
   that when the function is called we can know how to convert the
   arguments from Ruby types to C++ types.

2. In ruby-libjit (http://rubyforge.org/projects/ruby-libjit) I attach a
   jit-compiled function object to a method so that the function won't
   be destroyed unless the method it is implementing is removed.

3. In the ruby interpreter, struct.c could be extended to have O(1)
   access for all members of the struct, not just the first 10 (I have
   an unreleased extension that does just this).

In neither case is static data appropriate: in the first case, because
functions are being generated at compile-time, and in the second case,
because functions are being generated at run-time.

This was discussed in 2004 in old RCR#202, and Matz was concerned that
the solution was not re-entrant, but I don't believe this to be the
case.

Paul