Skip to content

Freeze user defined definitions of public methods #58919

@Tokazama

Description

@Tokazama

Sometimes we want a method that is public but users can't directly extend by providing a new definition. A simple case is Base.identity, which requires no warning for people to know that it doesn't make sense to create new definitions. Other cases like Base.deepcopy have explicit documentation to override Base.copy or Base.deepcopy_internal instead. However, there's no way to enforce this in code so that an error or warning is raised when a user defines a new method innapropriately.

I think the closest term for this would be freeze. I assume that freezing methods would make the most sense at the module level (e.g., freeze frozen_method1, frozen_method2). To be clear, what I'm proposing is distinct from some of the tools in Base.Experimental related to limiting method specialization by the compiler, and is only limiting explicit new definitions for a method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIndicates similar issues or pull requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions