Stream: beginners

Topic: Box


view this post on Zulip Artur Swiderski (Jun 10 2023 at 13:55):

what are use cases for this type, maybe put some example. What are pros and cons of it

view this post on Zulip Brendan Hansknecht (Jun 10 2023 at 18:25):

For most users, box really is never needed. It has 2 main use cases:

  1. Platform devs will need to use it for holding unknown roc types like a model.
  2. It can be used in some rare cases to improve performance.

In general, I would just say don't worry about it. Fundamentally it just puts something on the heap with a refcount instead of on the stack. That said, i think today it is missing some optimizations and generally should be ignored.

view this post on Zulip Anton (Jun 14 2023 at 09:10):

I've added some documentation for Box https://github.com/roc-lang/roc/pull/5553


Last updated: Jul 05 2025 at 12:14 UTC