Skip to content

Should "augment" be optional? #4377

Open
@munificent

Description

@munificent

The augmentations proposal currently says that the introductory declaration can't be marked augment and all augmenting declarations must be.

It's unambiguous that an augmenting declaration is augmenting: it has the same name as a previous declaration in the same augmentation context. That means we could make the keyword optional or eliminate it entirely. Should we?

Personally, I do like having it be explicit. Say you were to write:

class SomeVeryLongName { ... }

// Much later...

class SomeVeryLongName { ... }

You meant the latter to be an unrelated class but accidentally used the same name. If we allow implicit augmentation, instead of a simple name collision error, you'll get a cascade of errors for every part of the class that doesn't overlap properly. If, for example, they both happen to define methods with the same name but different signatures, you'll get errors in those methods. Perhaps worse, if they don't overlap, you'll just silently create one class that is the Frankenstein amalgamation of both.

I don't think augment is much ceremony and avoids those pitfalls. But I could be persuaded otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    augmentationsIssues related to the augmentations proposal.questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions