On Sun, Jun 17, 2012 at 2:26 PM, Jonathan S. Shapiro <[email protected]> wrote: > On Sun, Jun 17, 2012 at 9:51 AM, Elias Gabriel Amaral da Silva > <[email protected]> wrote: >> >> On Sat, Jun 16, 2012 at 6:11 PM, Jonathan S. Shapiro <[email protected]> >> wrote: >> >> > The platform-specific implementation type is not (and should not be) >> > revealed, but >> > We need to know that type in order to stack-allocate an instance. >> >> You don't, you need to know only its size. This means that a formal >> proof that your type has size N is enough (even if N is only known at >> run time), and then you pass this N to alloca. > > > Umm. Yes. I mis-spoke. > > To allocate, I agree that you only need to know the size. > > But to pass the resulting object back into a later procedure, you need > enough information to check type agreement at the procedure call boundary.
Whoever will receive this object has to provide a proof that it knows a way to access the object. This can be encoded in the type of the receiving function, too. You shouldn't need check if the types agree this at runtime. Maybe the problem is that alloca returns (a reference to) an untyped block of memory? If the receiving end sees only that, then it can't access it as if it were an object. Suppose the receiving end don't know which concrete type it will receive, but know it is from a given type class (that might or might not be equivalent to your supertype, I'm not sure). Now you need to assure (statically) that alloca will return a block that can be filled by an object whose type is a member of this class, and this should be reflected in the typing of alloca. If which type is returned is decided at compile time, you don't need to do any check at runtime because you already know what are the types. If somehow this is left to be decided at runtime, you need to check a finite number of cases when this object is returned (at most the number of instances of this type class). This wouldn't be something like "check type agreement", because you already know the types agree (so there is no possibility of raising an error). > But as I say above, this wouldn't be enough to check for type agreement when > the allocated object is passed back in. > > Though now that I think about it, full type agreement may not be required. > We're only going to be passing around a pointer to the supertype (the > generic interface), and we *do* know the type of that. I *think* that > reduces the problem down to ensuring that stack region safety is not > violated. But if you know the interface and you use only this interface, there is full type agreement. I must be confusing something or I don't understand what your problem is about. _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
