Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm probably misunderstanding the complexity of the problem, but wouldn't this be solvable by just defining the right calling convention?

"Any structures larger than x, or any structures marked with a marker type, are returned by the caller providing an outref to a buffer with correct size, and the callee directly writes the structure into that buffer."

Then you could just write normal code like

    fn initialize() -> A { 
    // the initialization code 
    }
and it would just work? And it would reduce unnecessary copies in a lot of other situations too? Given how much work has been put into this issue, and how much less convenient the proposed solutions are, I feel like I must be missing something.


The missing piece is that it would still force you to make even larger types in many cases, such as `Result<Large, Error>`.

Essentially the problem is composability. If you are building a large type from a sequence of other large types, and one or more step is fallible, the normal return ABI breaks down very quickly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: