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

wdte: add infix notation #120

Open
DeedleFake opened this issue Sep 16, 2018 · 1 comment
Open

wdte: add infix notation #120

DeedleFake opened this issue Sep 16, 2018 · 1 comment

Comments

@DeedleFake
Copy link
Owner

In Haskell, a function can be called in an infix position, such as arg1 func arg2, by surrounding the function name with backticks. I'm not a big fan of Haskell's particular syntax for infix notation, but support for some means of providing infix notation would be nice.

Current ideas:

  • {arg1 func arg2}, in which all three elements are <single>s. The downside is that an expression like {fib {n - 1} + fib {n - 2}} would be unparsable. {(fib {n - 1}) + (fib {n - 2})} would be fine, though, so it's probably fine, and extreme cases could just stick the arguments in variables first to make it cleaner.
  • arg1 {func} arg2, in which all three elements are arbitrary expressions. This seems a bit more awkward to parse and is depressingly similar to the Haskell notation.
@DeedleFake DeedleFake self-assigned this Sep 16, 2018
@DeedleFake DeedleFake added this to Todo in Initial Implementation via automation Sep 16, 2018
@DeedleFake
Copy link
Owner Author

After attempting to implement the first variant ({arg1 func arg2}), I have discovered a problem that affects both. The usage of { at the beginning of an expression introduces an ambiguity with switches, as switches start with switch <expr> {. This isn't an issue if the function at the beginning of <expr> is the infix expression, but if an argument is, such as in switch f {1 + 2} {, then the parser can't tell that the first { isn't the beginning of the switches cases.

The only solutions I can think of are either to use a completely different infix notation, or to change the <switch> syntax. I'm leaning towards the former, but I'm not quite sure what to use.

@DeedleFake DeedleFake changed the title Add Infix Notation wdte: add infix notation Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant