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

Implicit block overhaul #127

Open
satyr opened this issue Apr 18, 2012 · 2 comments
Open

Implicit block overhaul #127

satyr opened this issue Apr 18, 2012 · 2 comments

Comments

@satyr
Copy link
Owner

satyr commented Apr 18, 2012

The current rule for generating implicit block is too complicated to explain in a few sentences.

For example the following:

switch
case a then if b then c else d

doesn't parse, because the first then generates DEDENT before else.
You pretty much have to read through addImplicitIndentations to grok the rule.

So here's a proposal to make it simpler:

  1. Insert an implicit INDENT after an implicit block opener (then -> etc.) if the next token isn't NEWLINE or INDENT.
  2. Insert an implicit DEDENT before an implicit block closer (else catch etc.) if the last INDENT is implicit.

E.g.:

-> a
   b
# parses as
->
   a
   b

switch
case a then if b then c else d
# parses as
switch
case a
            if b
                      c
            else
                             d

Pros

Simpler, grokkable rule.

Cons

Incompatibility. Some code currently valid like

for k in o then let
  ...

will be invalid.

@satyr
Copy link
Owner Author

satyr commented Jul 13, 2012

To compensate the loss of then if then let etc., we can backport LiveScript's =>:

truthies = for x of xs => if x => x

The pipe operator can be |>.

@satyr
Copy link
Owner Author

satyr commented Jul 29, 2012

  • 7ebcdbc fixed the OP test case.
  • d0a3b1d enabled the Haskell-ish off-side rule via =>.

Making this less attractive, especially with the then-if incompatibility.

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

No branches or pull requests

1 participant