Skip to content

Guard statements #39

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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