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

Question: should we have indentation-insensitive variants of indentation-sensitive syntax? #32

Open
osa1 opened this issue Dec 30, 2024 · 1 comment
Labels

Comments

@osa1
Copy link
Member

osa1 commented Dec 30, 2024

Some languages like Haskell and Koka provide alternatives to indentation sensitive syntax that are not indentation sensitive, often with braces and semicolons. (note: I'm not sure if they have an indentation insensitive syntax for all indentation sensitive syntax)

Some languages like Python don't.

I'm not sure what are the use cases for having indentation insensitive variants of indentation sensitive syntax. Is this necessary?

Given that Python gets away without it I'm inclined towards not wasting time with this.

@osa1
Copy link
Member Author

osa1 commented Dec 31, 2024

Indnetation insensitive syntax can also be used single line if statements or match branches, and similar.

Currently we have these syntax:

match <expr>:
    <pattern>: <simple expr>

# or
match <expr>:
    <pattern>:
        <block>

I want to get rid of the :s, but that causes ambiguities in the single-line syntax:

C (a, b, c)

Which can be parsed as: C as the pattern, (a, b, c) as the right-hand side, or C(a, b, c) as the pattern.

With semicolons and braces, we can have just

match <expr>
    <pattern>
        <block>

and for single-line match alternatives use braces:

match x
  C(a, b, c)
    <expr>

match x
  C(a, b, c) { <expr> }

@osa1 osa1 added the syntax label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant