# Re: Associating data with a function

**URL:** <https://www.ruby-forum.com/t/re-associating-data-with-a-function/71070>\
**Category:** Ruby\
**Created:** [October 5, 2006, 5:51am UTC](https://www.ruby-forum.com/t/re-associating-data-with-a-function/71070 "2006-10-05T05:51:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 5, 2006, 5:51am UTC](https://www.ruby-forum.com/t/re-associating-data-with-a-function/71070/1 "2006-10-05T05:51:47Z")

</div>

From: Jan S. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> Another possibility is to implement a pool of objects directly into  
> ExpensiveObject or to create a layer above it.

That is an option, although I didn’t mention that one complicating  
factor is that all this is happening in a repetitive,  
update-frame-basis. I considered using object pools for a while, but it  
was annoying to have to have the object pool itself running every frame  
in order to reset the pool state, and to ensure that it ran before/after  
all other methods.

Plus, because speed is an issue here, I prefer solutions that don’t  
involve the overhead of a function/method call to get an Expensive  
instance. (Of course, such a pool could be managed less cleanly as a  
global array/index combo, or such.) But that’s less important for the  
Ruby solution.

Thanks for the contribution to the thread for posterity; it is important  
to keep pools in mind for this sort of problem.
