question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Close on decision regarding 0-based and 1-based coordinates in API

See original GitHub issue

https://github.com/xtermjs/xterm.js/pull/2470 added the 1-based interface IViewportCellPosition (uses col/row, aligns with how escape sequences work), https://github.com/xtermjs/xterm.js/issues/2480 will add IBufferCellPosition (x/y) which may be 0-based? Is that confusing? What should we do?

@mofux tells me monaco uses 1-based and language servers use 0-based. Maybe we should just use 0-based everywhere (should we avoid col/row in the API)?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Tyriarcommented, Oct 25, 2019

Ok, let’s go with 0-based and have the end range x be exclusive so it’s consistent everywhere as I think we have to keep selection like that.

1reaction
jerchcommented, Oct 19, 2019

Yes, imho all the confusion comes from natural language usage (or trying to apply simple counting rules - a mistake found in those very early programming languages as well). The 1-based cat is already out of the bag - hard to put it back…

Edit: Or to put it another way - for me the difference is whether we think in indices or item/object counts. Natural languages and/or common logic would prefer to refer to objects (where a 0th thingy does not make any sense). Index usage is very unpopular in such non programming or math related context (maybe we simply dont like indirections if we can just point to the “thing”, idk). Other point is the meaning of 0th here - its just nothing, or null? or empty set? or a non-object that if its the only element in a set would still leave the set empty? If treated in object realms as done in common logic we step right into all the set theory problems - which was not solved/satisfyied until Russell. All in all - “common every day logic” has prolly solved this for ages - nope, go away, thats “nothing”.

On the other hand in computing almost every data layout has an origin and uses indices to drive in some direction from that origin - in this context it is logical to call the origin 0. Most (un)famous prolly being a pointer address itself as offset from the memory segment start (byte index).

For 0th col - isnt that just applying the index to the item itself (kinda trying to skip the origin+index offset indirection)? Within a programming context or formal languages I am fine with this either, but not for common everyday logic. It would just drive ppl crazy and work against common counting rules - “if there is one thing, its the first thing” - “What the 0th thing here?” - Not defined in common context imho (or the universe might rip apart 😈)

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Are The Advantages/Disadvantages Of One-Based Vs ...
0-based, half open systems allow cheap length calculations. That is, m-n instead of (m-n)+1 in a 1-based, closed system. Also, 0-based is convenient...
Read more >
Start should be 1-based, not 0-based · Issue #251 - GitHub
In the Beacon specification, the start-key is described to be 0-based, while the VCF specification describes the position as 1-based; ...
Read more >
Google Maps API check if user is close to a marker
I have a json file with plenty GPS coordinates (lat,lng) which will be displayed as marker in Google Maps. Now I want to...
Read more >
How to correctly import Bismark coverage files into bsseq?
Use the 1-based coverage files from Bismark output. Bioconductor uses 1-based ranges so importing the 0-based coverage files would require ...
Read more >
bcftools(1) Manual Page - Samtools
The columns of the tab-delimited BED file are also CHROM, POS and END (trailing columns are ignored), but coordinates are 0-based, half-open.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found