icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Migrate to 0-indexed spans #669

Open ReeceHumphreys opened 10 months ago

ReeceHumphreys commented 10 months ago

Currently, our spans are 1-indexed to be more in line with how files are represented in editors. However, this has proven to be painful when implementing things like a language server, as the LSP protocol assumes 0-based positions. It would be nice to switch to using 0-based indexing for better compatibility with other tools.

pepone commented 10 months ago

If we change this we will have to fix the MSBuild task https://github.com/icerpc/icerpc-csharp/blob/0b36976cc3acb632e21c85f2982153cc0872f1ef/tools/IceRpc.Slice.Tools/SliceCCSharpTask.cs#L134-L142

So far there would be always tools that are 1-based or 0-based, we should pick one and stick with it.

ReeceHumphreys commented 10 months ago

If we change this we will have to fix the MSBuild task https://github.com/icerpc/icerpc-csharp/blob/0b36976cc3acb632e21c85f2982153cc0872f1ef/tools/IceRpc.Slice.Tools/SliceCCSharpTask.cs#L134-L142

So far there would be always tools that are 1-based or 0-based, we should pick one and stick with it.

Yes, I just think 0 based is more natural - we should do a survey of common tools and see if more are 0 based or 1 based. Generally for programming im inclined to assume things are 0 based.