> Patrick has some thoughts about splitting the concept of a destructable
> resource out into an orthogonal concept, independent of objects (so that it
> would not always incur a vtbl+heap allocation). Before we go too far down the
> road of prohibiting *all* objects from channels, we should probably think
> more about this scheme, and/or differentiating objects with dtors from those
> without.
Yeah, we were chatting a little about this. The scheme we came up with was
three layers (not taking into account the extra mutable-but-acyclic):
state
non-state, copyable
non-state, non-copyable
The graph showing which layers' data can have exterior pointers to which other
layers' data is a little subtle, even if you ignore the terribleness of my
ASCII art:
/v /v /v
+-+----+ +-+----+ +-+----+
| | | | | |
| NC +--->| C +<---+ S |
| | | | | |
+------+ +------+ +---+--+
^----------------------/
In more detail:
- Each layer's data can of course point to other data in that same layer.
- Stateful data can refer to any other data.
- Copyable data *can't* refer to non-copyable data, even through an exterior
pointer (because it could lead to the non-copyable data being shared across
tasks, which would require atomic refcounts).
- Non-copyable data *can* refer to copyable immutable data.
Does that seem about right?
Dave
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev