Skip to content

Define copy for immutable values #45143

@bkamins

Description

@bkamins

Following the discussion in https://discourse.julialang.org/t/coordinating-community-efforts-to-enrich-function-docs/80338/8 I propose to add the following catch-all method for copy (tentative):

function copy(x::T) where T
    ismutable(x) || return x
    throw(ArgumentError("copy for values of type $T is not supported."))
end

However, maybe there are reasons why there is no such definition present?

Metadata

Metadata

Assignees

No one assigned

    Labels

    designDesign of APIs or of the language itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions