Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #74 - Syntax sugar for block expression values #81

Merged
merged 1 commit into from
Jan 19, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jan 19, 2018

The block expression syntax sugar discussed in #42 and introduced in #74 allowed the closing brace of a block expression which is the only placeable in the pattern to be on the first column of the line, without indentation. Requiring the closing } to be indented had been reported as a papercut.

foo = {
   *[nominative] Foo
    [genitive] Foo's
}

The above syntax is desired and more intuitive and we'll try to make it possible in the future along with other changes relaxing the indentation requirement. For now, the block expression sugar can be surprising and it creates a false expectation that the closing } doesn't need to be indented.

It also creates a refactoring hazard: factoring a common part of the translation out of a block expression results in a syntax error:

# This is OK: the block expression is the only element in the Pattern.
new-messages = { $num ->
    [one] New message
   *[other] New messages
}

# Syntax Error at "}".
new-messages = New { $num ->
    [one] message
   *[other] messages
}

For the time being, the recommended formatting of block expression is to indent the entire body of the message:

new-messages =
    { $num ->
        [one] New message
       *[other] New messages
    }

The block expression syntax sugar allowed the closing brace of a block
expression which is the only placeable in the pattern to be on the first column
of the line, without indentation. Requiring the closing } to be indented had
been reported as a papercut.

    foo = {
       *[nominative] Foo
        [genitive] Foo's
    }

The above syntax is desired and more intuitive and we'll try to make it
possible in the future along with other changes relaxing the indentation
requirement. For now, the block expression sugar can be surprising and it
creates a false expectation that the closing } doesn't need to be indented.

It also creates a refactoring hazard: factoring a common part of the
translation out of a block expression results in a syntax error:

    # This is OK: the block expression is the only element in the Pattern.
    new-messages = { $num ->
        [one] New message
       *[other] New messages
    }

    # Syntax Error at "}".
    new-messages = New { $num ->
        [one] message
       *[other] messages
    }

For the time being, the recommended formatting of block expression is to indent
the entire body of the message:

    new-messages =
        { $num ->
            [one] New message
           *[other] New messages
        }
@Pike
Copy link
Contributor

Pike commented Jan 19, 2018

lgtm.

Copy link
Collaborator

@zbraniecki zbraniecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@stasm stasm merged commit 167833d into projectfluent:master Jan 19, 2018
@stasm stasm deleted the revert-block-expr-sugar branch January 19, 2018 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants