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

Decide whether line and column should be 0-based or 1-based #76

Closed
dmajda opened this issue Apr 20, 2012 · 4 comments
Closed

Decide whether line and column should be 0-based or 1-based #76

dmajda opened this issue Apr 20, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@dmajda
Copy link
Contributor

dmajda commented Apr 20, 2012

Currently all line and column indexes in PEG.js are 1-based. This is OK if this information is mostly presented to users, but it can inconvenient for machine processing where 0-based indexes would often work better.

The line and column indexes are currently visible on two places:

  • line and column properties of exceptions thrown on parse errors
  • line and column variables inside actions and predicates (available if the parser was built with the trackLineAndColumn option)

Indexing should be consistent on both.

For me, the question whether to have 0-based or 1-based reduces to a question whether the "display to users" or "use for computation" use case happens more often. I need to wait for users to adopt 0.7.0 (where position tracking was implemented for the first time) to answer that.

This was split off from #33 where this issue was raised by @paulftw.

@otac0n
Copy link

otac0n commented May 3, 2012

Is it possible to just make this a configurable option?

I would say that, in general, it is easier for a programmer to handle 1-based indices than it is for an end user to handle 0-based indices. So, I think the default of 1 is good, but if someone wanted to override it, that would be nice.

@dmajda
Copy link
Contributor Author

dmajda commented May 5, 2012

I would say that, in general, it is easier for a programmer to handle 1-based indices than it is for an end user to handle 0-based indices.

That's a sound argument, I like it.

Is it possible to just make this a configurable option?

No way :-) Something this trivial shouldn't be configurable.

@tonylukasavage
Copy link
Contributor

I vote 1-based. 0-based doens't make much sense in the context of line numbers

@ghost ghost assigned dmajda Nov 22, 2012
@dmajda
Copy link
Contributor Author

dmajda commented Nov 22, 2012

There were no additional complaints from users about this, so let's keep the current way. Closing.

@dmajda dmajda closed this as completed Nov 22, 2012
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

3 participants