Elektrine lite

← Feed

@zwarich@hachyderm.io

Post #3613080

2025-12-29 19:33 UTC

@joe@f.duriansoftware.com @foonathan@fosstodon.org @dotstdy@mastodon.social @ianh@mastodon.social I think most languages that would allow you to return borrows would let you also store them as struct fields, etc. and just add a borrowed pointer type, in which case you could just make a tuple of borrows. I guess you could take a purist "parameter modes" approach and define borrowed struct fields via parameter modes on the struct's constructor? However, I think it might be tricky to make this work well with generics. Another place where a similar distinction comes up is in-place construction of return values. Rust doesn't have this, but I assume that some successor language will want this to support internal self-reference, e.g. for efficient containers with inline capacity

Replies (1)

  • @joe@f.duriansoftware.com 2025-12-29 19:47

    @zwarich@hachyderm.io @foonathan@fosstodon.org @dotstdy@mastodon.social @ianh@mastodon.social yeah return value emplacement was the other thing i had in mind where a tuple (in its naive unexploded representation) isn't the same thing as multiple values. even with first-class borrows, the way swift tries to allow for tuples to be magically exploded and imploded by the implementation fights against the very concept of a borrow-of-tuple ever existing, since you really want a contiguous representation for that borrow to refer to

    Open ##3613079