Skip to content

void and pattern matching #6

@gkz

Description

@gkz

My concern with using void for this purpose in pattern matching, e.g. this example:

match (obj) {
  {x: void, y: void, ...rest}: ...
}

Is that in this context, I believe a reasonable interpretation (and perhaps one that comes to mind first for those not familiar with this feature) would be that we are matching for objects that do not have the properties x and y (or that they are undefined), given that it looks like we are "matching against void", rather than the properties x and y exist and can be any unknown value. This is because the void operator returns undefined, and type-systems like TypeScript and Flow use void as a type for either undefined or the lack of a value (i.e. void return).

I hope we can use _, even if only in the context of new syntax like extractors or match

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions