Skip to content

RFC: Return by move #3413

Closed
Closed
@catamorphism

Description

@catamorphism

In changing code to prepare for #2633, I'm noticing that most of the "copying a noncopyable" errors when I disable last-use have to do with a return, usually a return of a local variable. I propose that a return x should, by default, mean return (move x) when x is an owned lvalue. This avoids the need to insert lots of explicit moves once last-use is disabled.

An argument against this proposal is that the point of #2633 is to make more things explicit, and this proposal makes more things implicit again. However, I think it's easier to understand that "return is move" when you're returning something you own than it is to understand how last-use works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-type-systemArea: Type systemC-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions