Stream: compiler development

Topic: What traits should glue types support?


view this post on Zulip Sven van Caem (Oct 14 2024 at 14:35):

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:

view this post on Zulip Sven van Caem (Oct 14 2024 at 14:43):

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.

view this post on Zulip Sven van Caem (Oct 14 2024 at 14:51):

And if records implementing Ord _is_ desired behavior, should tag unions implement it too?

view this post on Zulip Brendan Hansknecht (Oct 14 2024 at 15:08):

Clone is not safe. At least not today.

view this post on Zulip Brendan Hansknecht (Oct 14 2024 at 15:09):

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

view this post on Zulip Brendan Hansknecht (Oct 14 2024 at 15:12):

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.

view this post on Zulip Brendan Hansknecht (Oct 14 2024 at 15:12):

I think tags and records should both be the same, but I'm not sure if that should be with or without ord

view this post on Zulip Sven van Caem (Oct 15 2024 at 06:53):

Gotcha, I think I'll leave it off for now then


Last updated: Jul 06 2025 at 12:14 UTC