ghost-cell icon indicating copy to clipboard operation
ghost-cell copied to clipboard

Would it be possible to break the creation of "brands" into a subcrate?

Open TheButlah opened this issue 3 years ago • 3 comments

I think the value of branding types with lifetimes is useful outside of just GhostCell. Would this be useful as a separate crate?

TheButlah avatar Jul 12 '22 23:07 TheButlah

I do not know.

There are multiple crates that use branding that I know of:

  • https://crates.io/crates/qcell has a variant of GhostCell,
  • https://github.com/bluss/indexing uses them to brand indexes known to be in-bounds.

And doubtless many others as people experiment with the concept.

I haven't done any survey to check what kind of API each of those different crates would require, and thus I cannot say whether it would be possible to have a generic API for it.

matthieu-m avatar Jul 13 '22 16:07 matthieu-m

Of particular note might now be the generativity crate, which neatly abstracts creation of a brand into a macro such that it no longer requires closures / scopes. Also it is at 1 and essentially done which should provide reasonable interoperability and reuse. It could be an optional dependency adding merely a From<Guard<'id>> for GhostToken<'id> implementation, I reckon.

197g avatar Nov 24 '23 16:11 197g

Of particular note might now be the generativity crate, which neatly abstracts creation of a brand into a macro such that it no longer requires closures / scopes.

First of all, I am afraid I am not in a position to judge whether generativity is sound, or not. The appeal of GhostCell is that it is implemented from a paper which formally verified the soundness of the solution, and I would rather not forego this guarantee.

The next question, then, would be: what happens if generativity is proven sound?

I must admit I would be unsure of the relative benefit of integrating into GhostCell versus having a new crate spring up purely based on generativity. It would depend, I expect, on exactly how different an API could be crafted with generativity. If minor, it may be worth it, but given how young the API is, perhaps it would be worth taking the opportunity to overhaul the API instead. I can't say as of today, and I don't really have the time to explore the space unfortunately.

And of course, it is also quite possible that another existing crate may just prove better adapted to the pattern, and there would be little point in creating a mirror.

matthieu-m avatar Nov 24 '23 17:11 matthieu-m