On 2009-12-17 10:51:04 -0500, Andrei Alexandrescu <[email protected]> said:

Michel Fortin wrote:
I have a problem where I want to store rebindable references to other objects, but I also want to ensure those objects are immutable. Basically, the Rebindable template in std.typecons should do the job, but it appears that it does not work with forward references...

Going further, I've made this simple test case and I'm left wondering if there is a way for the compiler to make that work in the future. Basically, the definition of each class depends on the other class. Can the compiler instantiate a template using a partially defined class? One of the template has to be instantiate before the other, obviously.

import std.typecons;

class A {
    Rebindable!(const B) r;
}

class B {
    Rebindable!(const A) r;
}

I'm not sure if I really want to use this pattern; this is just an experiment I made. But it looks quite limiting not to be able to do that.


This is a bug. Could you please file it in bugzilla?

Here: <http://d.puremagic.com/issues/show_bug.cgi?id=3625>

It turns out the 'get' member of Rebindable is unusable too (unless you're in the same module). It's already reported: <http://d.puremagic.com/issues/show_bug.cgi?id=3318>.

In fact, I'd have liked to get rid of 'get' in Rebindable and use alias this instead so that it behaves like any other object reference, but I'm running into another problem, so that'll have to wait. Bug: <http://d.puremagic.com/issues/show_bug.cgi?id=3626>


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to