Skip to content

Guard statements #39

@wongjiahau

Description

@wongjiahau

This proposal is a breaking change.

The previous if keyword needs to be changed to case, and else need to be changed to default.

Why?

Consider we wants to create the following function:

(this Int).compare(that Int) = 
    this.==(that).
        case(true):
            (0)
        case(false):
            (this.>(that).
                case(true):
                    (1)
                case(false):
                    (1.negate))

That is tedious, so we should do like this instead:

(this Int).compare(that Int) = 
    this.
        if(.==(that)):
            (0)
        if(.>(that)):
            (1)
        else:
            (1.negate)

Is much more cleaner, however, needs more revision on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions