Dear Mr. Matz,

Probably the most direct problem that I am currently facing is, I will
have many entities that will be created and destroyed so often (millions
of times) such as packets and events.  If the user is not going to have
access to these entities, I can create efficient structures for them (even
probably manage the memory usage.)  However, when a user is allowed to
interact with them, I am forced to make the packets and events as Ruby
objects (to be honest, I don't know how much overhead the Ruby objects
have as compared to straight C structs; I have not made comparison yet.)

I am thinking whether it is possible to design some "lazy evaluation" type
of object.  In other words, when the user does not interact with them,
they are straight C structs so that the code is highly efficient.  Once a
user interact with an entity, however, the struct creates a Ruby object
for the user to interface.

Another (simpler) example is when I want to reuse Ruby array in C, it
forces all the entities to be Ruby objects, because a Ruby array, I think,
cannot hold objects other than Ruby objects.  So if I just want to have a
(dynamic) array of double's, I am forced to create objects of type
rb_cFloat instead of straight C double's.  (Of course, in this case the
solution is to use other C libraries.)

Regards,

Bill
=========================================================================
Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> |The reason is, for efficiency purposes, sometimes I may want to get to the
> |underlying C function directly, instead of calling "rb_funcall".  Probably
> |to be efficient, I have to define my own structures and
> |functions; however, often this is difficult as Ruby requires all
> |user-accessible objects to be of type VALUE.

> I'm not sure why it is difficult.  Could you tell me how difficult?

> 							matz.