Login
You're viewing the functional.cafe public feed.
  • Nov 16, 2026, 8:35 PM

    To be fair, I'm kinda conflating the Box type with reference types more generally. It's possible to make other mutable data types with their own mutation vocabulary - for example, a large bloom filter that allows you to atomically store a hash value, or check if that value is set. You *could* use the Box type to wrap a buffer for this, but it would be non-ideal in a couple ways.

    1. You could cheaply read it (copy-on-write), sure, but that's overkill for checking a single bit.
    2. You can't cheaply write to it, because any edits require a copy (one copy is owned by the Box itself).

    So a custom interface makes sense! But Box is still a good tutorial of the flavor that all of these interfaces have - explicit loads and stores, just at a range of granularities we don't often get in a language.

    💬 1🔄 0⭐ 0

Replies

  • 💬 0🔄 0⭐ 0
  • Nov 16, 2026, 9:33 PM

    @LunaDragofelis yyyes, ma'am, that they rightly can! The model is really that these are handles, which are almost pure data (you could model them as int IDs that you get and set the underlying values with service functions), with the main exception being reference counting.

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • Nov 16, 2026, 9:41 PM

    @LunaDragofelis That's the neat part! You don't! Pure data is acyclic, so reference counting is formally correct. Reference types can introduce cycles because they behave like GC roots. But in a properly structured program, these are rare enough to think about manually. Think "unsafe" in Rust, but only in terms of stigma. Prone ref types are safe but culturally gross.

    💬 0🔄 0⭐ 0