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

Change “consume” to “commit” #205

Open
jamesdbrock opened this issue Sep 15, 2022 · 3 comments
Open

Change “consume” to “commit” #205

jamesdbrock opened this issue Sep 15, 2022 · 3 comments

Comments

@jamesdbrock
Copy link
Member

I want to change the term “consume” everywhere to “commit.”

The term “consume” is inherited from the early days of Parsec ( Parsec: Direct Style Monadic Parser Combinators For The Real World section 3 Restricting Lookahead ), but it is very confusing. The term “commit” much better conveys the meaning of “fail the parse right here instead of trying the alternative parse.”

In addition, we should talk explicitly about “backtracking” in the documentation. We always allow arbitrary backtracking, so the entire input stream is always held in memory.

Maybe primitive parsers should never commit (and should always backtrack, as they do now)? Maybe an alt branch should only be commited by explicitly calling the commit function? That would be a very breaking change.

The term for moving forward in the input stream is “advance,” as in Parsing.Combinators.advance.

@JordanMartinez
Copy link
Contributor

👍 from me about using the term 'commit'.

@natefaubion
Copy link
Contributor

Maybe an alt branch should only be commited by explicitly calling the commit function? That would be a very breaking change.

This is a very different style of parser. There's nothing wrong with it, it's just a very different way of writing parsers, and it seems really odd to arbitrarily switch to it. It's not fundamentally more expressive, or even easier, it's just inverting the mechanism while also coming with it's own set of downsides. This is essentially the age-old "backtrack by default" argument.

@jamesdbrock
Copy link
Member Author

“commit” is the term used everywhere in Elm parser https://package.elm-lang.org/packages/elm/parser/latest/

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

No branches or pull requests

3 participants