Closed
Description
As described here:
http://smallcultfollowing.com/babysteps/blog/2013/04/30/dynamically-sized-types/
Rough notes on the plan:
-
Thinking about dynamically sized types. What needs to change:
- trans code:
- need to ensure that all dynamically sized types have a consistent
layout (e.g., (ptr, meta))- change repr of
~[T]
,~str
, `~Trait', etc - change repr of ~Trait to be a pair, moving type descriptor into vtable
- change repr of @fn, ~fn, &fn to skip header for &fn pointer
- change repr of
- make the various Datum routines for deref'ing and so forth do
the right thing based on thety::t
- not sure what other places in the code think they know about
the structure of a pointer, probably a few - we could keep the types as they are now and get this part right,
by essentially translating in trans from something like
AutoBorrowVec
into the combination ofdatum.deref()
and then
datum.take_ref()
- not sure what other places in the code think they know about
- at type system level, 9then, we'll want to:
- implement kind bounds on fns (I can do that relatively easily)
- any other changes that would stand in the way of types being
separated from&
etc - do the change
- need to ensure that all dynamically sized types have a consistent
- trans code:
-
Semantic questions:
- [a, b, c] has type [T, ..3]
- ~[a, b, c] has type ~[T]
- [a, b, c] --> [T]
- Relevant to custom smart pointer types:
- If we for a DWIM solution:
- ~([a, b, c]) <-- what should this do?
- basically we'll propagate information from ~ operator, @ operator, etc
-
Modify kindck (probably?) to enforce Sized requirement
- good idea to do this early, gives us an idea of the burden aspect
- maybe move existing code to kindck as a first step?
-
We may want to allow kind bounds of type definitions:
struct Foo {
vec: ~[T] <--- we would want to know here that T:Sized
}or maybe just enforce this bound at use points instead
To be implemented by @pcwalton and @nikomatsakis.