Stream: beginners

Topic: Example of hosted effect that takes a record as a parameter?


view this post on Zulip Jared Cone (Oct 09 2024 at 06:24):

Are there any examples that have a platform that has a hosted effect that takes a record as a parameter? Such as

Data : { x : I32 }

doSomethingWithData : Data -> Task {} {}

view this post on Zulip Luke Boswell (Oct 09 2024 at 06:43):

Here's an example https://github.com/roc-lang/basic-cli/blob/9170961a537030b1aa5880774ff14d0c1f30b40c/crates/roc_host/src/lib.rs#L902

view this post on Zulip Jared Cone (Oct 09 2024 at 14:45):

Thanks!

view this post on Zulip Jared Cone (Oct 10 2024 at 01:57):

do records have to be boxed? Looking at sendRequest : Box Request -> Task InternalResponse []

view this post on Zulip Luke Boswell (Oct 10 2024 at 02:01):

No

view this post on Zulip Luke Boswell (Oct 10 2024 at 02:01):

If you Box it, roc will store the data on the heap and pass by pointer

I think it uses roc_alloc provided by the platform

view this post on Zulip Jared Cone (Oct 10 2024 at 02:07):

If I'm not boxing, is it possible I'm going to run into ABI issues like with Result? I'm trying to pass a record by value in the zig platform and not having good results yet

view this post on Zulip Brendan Hansknecht (Oct 10 2024 at 02:08):

is it possible I'm going to run into ABI issues like with Result?

Yes, but a lot less likely

view this post on Zulip Luke Boswell (Oct 10 2024 at 02:09):

I would say it's definitely possible to bump into ABI issues. This area isn't very well explored. Usually it's like @Brendan Hansknecht and myself figuring this out as we go. There are definitely known and unkown bugs we run into regularly.


Last updated: Jul 06 2025 at 12:14 UTC