Hi Sylvain,

On Dec 16, 2:11 pm, Sylvain Joyeux <[email protected]> wrote:
> Hello everyone,
>
> First, a bit of background. Then I'll explain what hack I implemented
> on MRI ... and ask you how it could be done on Rubinius.
>
> I'm the developper of a Ruby-based supervision framework for robotics.
> In there, I implemented some transaction environment that allows to
> sandbox changes made on some objects, and then apply them all at the
> same time.
>
> The issue I had was that the "transaction proxy", the object that
> records the changes, can be captured into closures. And, therefore,
> needs to be a perfect delegate of the real object once the transaction
> is committed. One solution would have been to modify the object's
> metaclass in order to make it a delegate, but that was *really* bad
> performance wise.
>
> I therefore implemented a (horrible) C extension hack: I actually swap
> the RObject descriptor of the transaction proxy with the one of a
> fresh delegate object. It results with having all variables that were
> pointing to the proxy to now point to the delegate, and to have the
> actual transaction proxy be GCed later on.

EWWWW.

>
> Ugly, not robust and very MRI-specific.
>
> Now, I'm really interested in evaluating how good Rubinius is, since
> I'm confident it will become a much better implementation of Ruby than
> MRI itself.
>
> I would therefore like to solve the problem of *efficiently* turning
> an object into a delegate, possibly writing some C++ code to achieve
> that. Could you point me to *how* ?
>
> Looking at the basic classes, I already saw that it was possible to
> copy metaclasses. Would it be possible to replace the proxie's
> metaclass by a prepared delegate implementation ? Or maybe replace the
> actual object's class on the fly ?
>
> Any input would be appreciated.

Could you give me some ruby code that shows the behavior you need?

Your situation is interested, and I want to be sure I'm fully
understanding it before looking into a solution.

 - Evan

>
> Sylvain

-- 
--- !ruby/object:MailingList
name: rubinius-dev
view: http://groups.google.com/group/rubinius-dev?hl=en
post: [email protected]
unsubscribe: [email protected]

Reply via email to