Currently, RustGlue.roc only generates a derived Debug implementation for RocFunction types:
#[repr(C)]
#[derive(Debug)]
pub struct RocFunction_65 {
closure_data: Vec<u8>,
}
Some thoughts on this:
Clone
would be safe to implement and wouldn't hurt to include.Relatedly, generated record types currently derive PartialOrd
and Ord
. This allows a platform author to sort records by their fields, ranked by the order they appear in memory. Is this to allow for e.g: binary search on sorted lists of records? I thought I'd double check whether this might be a mistake, because outside of that one use-case, it seems like its behavior might be confusing to a platform author.
And if records implementing Ord
_is_ desired behavior, should tag unions implement it too?
Clone is not safe. At least not today.
If you clone the raw closure capture, you may clone something refcounted. But you wouldn't increment the refcount. So roc will free it, but you will still have a reference to the old memory address
As for ord....just a convenience if the platform happens to want it. Honestly, it may not really be useful. I'm not sure of a specific use case past sorting.
I think tags and records should both be the same, but I'm not sure if that should be with or without ord
Gotcha, I think I'll leave it off for now then
Last updated: Jul 06 2025 at 12:14 UTC