On 26/02/2015 9:37 AM, Jonathan S. Shapiro wrote:
I really do not see a solution to this **other than** allowing one
struct to extend another and introducing the capacity for dynamic
downcast. The problem here combines "is a kind of" with "is
identically a", and it is driven by data layout concerns rather than
any need for existential encapsulation.
I'm assuming the scenarios you're thinking of are like the following
conceptual EROS-like message sending code:
enum ObjTypes : int8 { Process, Node, Page, ... }
struct ObjectHeader { ObjTypes type_code; uint64 id, ... }
struct Process : ObjectHeader { struct Capability[32] cap_node; ... }
struct Capability { uin64 id; uint16 facet; ... }
// global table of in-memory objects, ie. processes, nodes, pages, etc.
static struct ObjectHeader[] global_obj_table;
static struct Process* running;
// kernel system call entry point
void kernel_msg_send(unsigned cap_idx, struct Message *msg) {
let cap = running->cap_node[cap_idx];
let obj = hash_lookup(global_obj_table, cap.id);
typecase(obj) {
case Process p -> // send msg to process p
case Node n -> // send msg to kernel object n
...
}
}
Since you want fully prescriptive layouts, presumably you'll want
typecase to be some sort of projection from the underlying record, in
this case defined by the type_code field, but a safe, yet fully
prescriptive solution seems to get perilously close to dependent typing.
I'm curious how you think this would actually work before I comment further.
Sandro
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev