Zero / One based arrays - finding out which !?

This forum is meant for questions and discussions about the X# language and tools
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

Zero / One based arrays - finding out which !?

Post by Phil Hepburn »

Hi Wolfgang,

yes, of course this is a possible issue ;-0)

just because a method is STATIC does not say that it MUST be housed / kept in a class library outside of the current Project.

After all, a STATIC method is really just a function.

Can you think of any other useful properties which are project dependant and likely to need my attention ?

Regards,
Phil.
User avatar
wriedmann
Posts: 3765
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Zero / One based arrays - finding out which !?

Post by wriedmann »

Hi Phil,
Can you think of any other useful properties which are project dependant and likely to need my attention ?
If I look at all the compiler options, this one seems to be the only dangerous one.
Change it in a working application and the application will not work anymore....

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Zero / One based arrays - finding out which !?

Post by Frank Maraite »

Phil,
Wolfgang

as long as you have your unit tests working there is nothing dangerous.

Phil, during the time your are searching a solution you could have changed hundreds or thousands lines of code to the zero based approach. I bet in most cases it is from
for i := 1 to count
to
for i := 0 to count-1
only.
Count the key strokes. Then you know what is faster. And think about compiler pragmas. They are not spported now but I hope in the next future. Wait until this. Then you can change class for class, entity for entity, switching az on and off within your code.

All other approaches lead into confusion I think and make it bit harder to change to collections. I would avoid any tricks even I said cool! to Wolfgangs solution. But thinking a while on it: who knows in a few years what's behind FirstIndex? Is this only the zero thing or does it have context dependend meaning? From my point of view it makes code less readable.

Frank
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

Zero / One based arrays - finding out which !?

Post by Phil Hepburn »

Frank, Wolfgang, all,

I appreciate that this is an issue which needs some careful thought, however, as a start I can't see anything too wrong with what I have working in the sample shown in the two images below. It should work for all types of .NET array.
ArrayBounds_01.jpg
ArrayBounds_01.jpg (96.33 KiB) Viewed 273 times
ArrayBounds_02.jpg
ArrayBounds_02.jpg (140.68 KiB) Viewed 273 times
Polymorphism works in our favour on line 209 :P

Have a nice evening,
Phil.

P.S. please realise that the inserted code is still just work in progress for the Cologne conference sessions in April 2018.
Post Reply