zetzit / zz

πŸΊπŸ™ ZetZ a zymbolic verifier and tranzpiler to bare metal C
MIT License
1.6k stars 52 forks source link

allow tail of to void* #105

Closed aep closed 4 years ago

aep commented 4 years ago

this enables building functions that take "any object and its size", specifically memory pools for generic containers.

Since we do not allow template functions, this is getting us closer to generic functions

i'd imagine something like

struct List+ {
    pool:Pool+ pool;
}

fn append(List+lt * self, void+vt * item)
{
    void *store = self->pool.alloc(vt);
    mem::cpy(item, store, vt);
}
jwerle commented 4 years ago

ohhhh yeah! checking this out now

aep commented 4 years ago

there's a pretty ugly edge case

 fn dump(void+vt * obj) {
    log::info("dumping object of size %d", vt);
}

fn ftail(Buffer+xt * obj) {
   dump(obj);
}

call to dump binds any explicit type tail binding first, so in this case whatever xt is instead of sizeof(Buffer) + xt

i should probably research how to auto cast into slice instead.

aep commented 4 years ago

never mind, i fixed it instead

jwerle commented 4 years ago

nice hell yeah