• SorteKaninOPA
    link
    fedilink
    arrow-up
    5
    ·
    4 days ago

    How do I now actually get a &Arc? Without implicitly cloning?

    & is such a fundamental part of the syntax, I really don’t think it’s meaning should be muddled.

    • INeedMana@piefed.zip
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 days ago

      What’s the use-case for &Arc? Modifying an Arc object in outer scope?

      To me, this handle trait sounds a lot like “reference-counted reference”. When there already exists a pure “reference” in the language

      • SorteKaninOPA
        link
        fedilink
        arrow-up
        1
        ·
        4 days ago

        I don’t know but it could be anything else than an Arc. Obviously you should still be able to take a usual reference to such a thing.

        References are just pointers, they don’t have any counting. This proposal as I understand it is an attempt at making reference-counting more ergonomic.

        • INeedMana@piefed.zip
          link
          fedilink
          English
          arrow-up
          2
          ·
          4 days ago

          I don’t know but it could be anything else than an Arc. Obviously you should still be able to take a usual reference to such a thing.

          Maybe. My point is that unless you want to, for example, have a reference that you switch between which object it references, I think you would be fine with using the ref-counted reference. With eventual optimization done via compiler when it’s sure the code won’t be trying to access the object after it got deleted. But even if I’m wrong, there could be another way to get a pure reference

          This proposal as I understand it is an attempt at making reference-counting more ergonomic.

          Yes, and IMO by using Handle for that it breaks a pattern. Rust keeps * and & for speaking about values and memory management (I want data vs I want reference). Using a trait for ref-counted referencing adds another layer. So suddenly we have *, & and ::Handle(). You see what I’m getting at?