Hi,

I've just read your proposal. It is pretty similar to an idea I had over the weekend. However, there is one thing I want to ask about. But I will present my idea because it may be the case that I misunderstood some part from your proposal.

My idea was to introduce few orthogonal concepts and use them together to solve the DOM problem:

1) single static inheritance and static cast to base types
2) virtual struct WITHOUT any virtual methods
3) dynamic cast to derived type or implemented trait for virtual structs

Structs that are declared virtual will have a hidden pointer to some vtable-like structure that allows dynamic casting to derived types and to traits. So the layout is similar to C++'s virtual classes, but there are no virtual methods. Instead, you would be able to cast to any implemented trait dynamically. If I understand your proposal correctly, it is the same as the Fat<T as U> relation.

I see that this Fat<T as U> relation is absolutely doable, but I was not able to come up with any efficient solution and I see performance of the dynamic cast as very important property. Otherwise the feature will be very useful.

My baseline solution was to build hashtable for every crate with key of pair (T,U) and search the hashtables when the dynamic cast is requested. That was just a proof that it is doable because it is not efficient solution. I also expect that some v-table structure can be generated for each virtual struct as far as we know all the implemented traits. (E.g., at link time for entire crate.) But when I considered implementing traits for virtual struct from different crate, it became more difficult and I stopped examining the problem.

So my questions would be:
Did I understood the meaning of the Fat<> relation correctly?

Is the Fat<> relation already implemented? Or is there a proposal for the implementation somewhere?

J

On 03/15/2014 05:30 AM, Micah Chalmer wrote:
I wrote up an alternative proposal that I think, if I’m understanding them 
correctly, meets all the requirements.  I submitted it as an RFC, so discussion 
of it is probably better put on github on the mailing list, but in case anyone 
interested is watching this thread and not watching the RFCs:

https://github.com/rust-lang/rfcs/pull/9

-Micah

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to