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

C# 8 - System.Index #2148

Closed
Korporal opened this issue Jan 16, 2019 · 90 comments
Closed

C# 8 - System.Index #2148

Korporal opened this issue Jan 16, 2019 · 90 comments

Comments

@Korporal
Copy link

Korporal commented Jan 16, 2019

I'm playing with VS 2019 and building a project with C# 8, however the use of ^ is hampered because the compiler cant find System.Index. I have no idea where that is and it doesn't seem to be a nuget package. So am I able to use ^ in VS 2019 yet or not?

@YairHalberstadt
Copy link
Contributor

Is the project .net core, .net standard or .net framework?

@akarpov89
Copy link

@Korporal You should target .NET Core 3.0 in order to make System.Index and System.Range available.

@jnm2
Copy link
Contributor

jnm2 commented Jan 17, 2019

@Korporal If you don't want to target notecoreapp3.0, another option is to copy and implement the API surface area of System.Index and System.Range into your project. For library projects, this is only a good idea if they stay internal. Otherwise you will have conflicts down the road when a project uses your library but already has these types defined in another library.

@popcatalin81
Copy link

Why isn't this a .Net standard package instead of .Net Core one?

@jnm2
Copy link
Contributor

jnm2 commented Jan 17, 2019

@popcatalin81 It is being added to .NET Standard 2.1. https://blogs.msdn.microsoft.com/dotnet/2018/11/12/building-c-8-0/

Platform dependencies

Most of the C# 8.0 language features will run on any version of .NET. However, a few of them have platform dependencies.

Async streams, indexers and ranges all rely on new framework types that will be part of .NET Standard 2.1. As Immo describes in his post Announcing .NET Standard 2.1, .NET Core 3.0 as well as Xamarin, Unity and Mono will all implement .NET Standard 2.1, but .NET Framework 4.8 will not. This means that the types required to use these features won’t be available when you target C# 8.0 to .NET Framework 4.8.

From memory, which is more or less accurate, but I don't have references:

.NET Standard packages like System.ValueTuple conflict with adding the types in-box for .NET Core 3.0. Moving types in-box has caused no end of tooling bugs and headaches for the team. They want it in-box for C# 3.0 because they don't want to add an entire separate package just to hold these couple of types.

@akarpov89
Copy link

I asked @terrajobst if they plan to create a nuget package exposing System.Index and System.Range for target frameworks other than .NET Core 3.0 a while ago on twitter (https://twitter.com/akarpov89/status/1074804447627395072) and he gave me a good explanation:

To avoid the disaster that was System.ValueTuple we'll first ship .NET Core 3.0 / .NET Standard 2.1 that offer built-in support and then we'll figure out the down-level story. In general, providing a package for a platform-level exchange type is hard & fragile.
Also, I'm not sure they are worth it as we cannot provide support for indexers on strings and arrays that would take Index/Range as those requrie updating the platform, so there would be a significant loss in fidelity.
Plus, shipping out-of-band by definition requires a new assembly which for core types like these seems very undesirable as we already have too many. So my goal would be to say no down level, but we'l; say. Engineering reality is rarely pretty :-)

@Korporal
Copy link
Author

Korporal commented Jan 21, 2019

Well I had little time to explore yet, but I just created a 2019 console app (seems to target .Net Core 2.1 by default and no other .Net Core version seems to be present). Anyway I found (on nuget) a package named

sdcb.System.Range although this doesn't seem to be Microsoft.

@Korporal
Copy link
Author

Korporal commented Jan 21, 2019

I do think that the syntax that was settled on for this is poor and the lack of symmetry when accessing the "first" element and "last" element is horrible. I wonder if these would have been better:

var x = array[<3]; // rather than array[^3] - i.e. we're perceiving the array from right-to-left

then add support for this (while still supporting [3])

var x = array[>3]; // a way to write array[3] - i.e. we're perceiving the array from left-to-right

along with 0 always referring to lowest indexed element and highest indexed element depending on whether < (or, sadly, in reality ^) is used. This would enable developers to write code that uses both "directions" in a clearer manner if they so chose.

There may be good reasons why the team did it they way they did, but the lack of symmetry makes no sense to me and will no doubt lead to subtle bugs where code is using both kinds of subscripts (perhaps calculating those subscripts) to fiddle with arrays and the developer simply forgot that 0 is first and ^1 is last!

As I said elsewhere the index/subscript could have been defined as either the +ve offset from the "first" element or -ve offset from the "last" element. As it stands now ^X means "negative offset X from last element + 1".

Is it too late to change this?

@HaloFour
Copy link
Contributor

HaloFour commented Jan 21, 2019

but the lack of symmetry makes no sense to me

When you start with an incorrect assumption any conclusion will be unreliable.

will no doubt lead to subtle bugs where code is using both kinds of subscripts (perhaps calculating those subscripts) to fiddle with arrays and the developer simply forgot that 0 is first and ^1 is last!

Those same developers also had to learn that array[array.Length] didn't point to an element.

Is it too late to change this?

It's not a question of time, it's a question of justification. One person vehemently disliking something on the Internet is far from a reason for the team to reverse design decisions that came out of numerous design meetings and prototypes.

@Korporal
Copy link
Author

Korporal commented Jan 21, 2019

but the lack of symmetry makes no sense to me

When you start with an incorrect assumption any conclusion will be unreliable.

will no doubt lead to subtle bugs where code is using both kinds of subscripts (perhaps calculating those subscripts) to fiddle with arrays and the developer simply forgot that 0 is first and ^1 is last!

Those same developers also had to learn that array[array.Length] didn't point to an element.

Is it too late to change this?

It's not a question of time, it's a question of justification. One person vehemently disliking something on the Internet is far from a reason for the team to reverse design decisions that came out of numerous design meetings and prototypes.

@HaloFour - Understood. But can anyone explain what advantages the chosen approach has over my suggested one? I'd truly like to understand the reasoning here.

Thanks.

@YairHalberstadt
Copy link
Contributor

YairHalberstadt commented Jan 21, 2019

But can anyone explain what advantages the chosen approach has over my suggested one? I'd truly like to understand the reasoning here.

Complexity. You are suggesting adding two syntaxes, both of which people have to learn, and both of which would be easy to confuse, instead of just one. Instead of just remembering that ^1 points to the last element, they've got to remember which one of >1 and <1 points to the last element.

@Korporal
Copy link
Author

Korporal commented Jan 21, 2019

But can anyone explain what advantages the chosen approach has over my suggested one? I'd truly like to understand the reasoning here.

Complexity. You are suggesting adding two syntaxes, both of which people have to learn, and both of which would be easy to confuse, instead of just one. Instead of just remembering that ^1 points to the last element, they've got to remember which one of >1 and <1 points to the last element.

But can anyone explain what advantages the chosen approach has over my suggested one? I'd truly like to understand the reasoning here.

Complexity. You are suggesting adding two syntaxes, both of which people have to learn, and both of which would be easy to confuse, instead of just one. Instead of just remembering that ^1 points to the last element, they've got to remember which one of >1 and <1 points to the last element.

@YairHalberstadt

Except that >1 would (or [1]) point to the second element - see even you're confused!

I find it hard to accept that the tokens GT or LT when found within [ GT | {LT} <expression> ] is to be regarded as "complex". In reality the usage and need to remember that 0 is first and ^1 is last is more complex for the reader and writer of the language - it's that complexity that needs to be considered I would argue. You should ask yourself how would someone who knew C# interpret code they see for the first time that's using ^ - I'm confident that most readers of such code would naturally assume ^0 meant last element - did you ask around?

Just watch, once this is full released and available to all for production code you're going to see articles and blogs decrying this design.

@HaloFour
Copy link
Contributor

@Korporal

Understood. But can anyone explain what advantages the chosen approach has over my suggested one? I'd truly like to understand the reasoning here.

The onus would be on you to demonstrate why your suggestion is considerably better.

I'd argue that < is worse because it implies that it affects the clusivity of a given range, not the position of the index. Ranges are always end exclusive. Beyond that I don't see why < is any better than ^.

Except that >1 would (or [1]) point to the second element - see even you're confused!

1 already points to the position before the second element. There's no need for any new syntax there.

@Korporal
Copy link
Author

Korporal commented Jan 21, 2019

@HaloFour

1 already points to the position before the second element. There's no need for any new syntax there.

I'm not arguing that < is needed but that it naturally arises from the choice to introduce a new operator for reverse sub-scripting. Once you decide that arrays can now be accessed bidirectionally then that decision leads to the suggestion for supporting two operators as an improved way of expressing code that relies on directionality.

Prior to ^ a subscript was a subscript value with one meaning but as soon as you introduce ^ you change that and so it seems natural to me to reflect that symmetry linguistically and allow (optional) use of >.

@Korporal
Copy link
Author

Anyway I guess nobody's in a position to review the decision, its cast in stone - so be it!

@HaloFour
Copy link
Contributor

@Korporal

Just watch, once this is full released and available to all for production code you're going to see articles and blogs decrying this design.

This is true of literally every language decision made by the C# team. If they didn't design features out of fear that someone somewhere would disagree loudly they'd literally never design anything.

it seems natural to me to reflect that symmetry linguistically

The symmetry of ^ has been explained multiple times.

Anyway I guess nobody's in a position to review the decision, its cast in stone - so be it!

It's certainly up for review, nothing is cast in stone until the feature ships. The ^ operator was chosen as a strawman, but you'd have to demonstrate why < or anything else is better than it, enough that someone on the language design team is willing to make the argument. I'm not saying that won't happen. Clusivity issue aside I don't find it any worse than ^, but that's not necessarily a reason to consider it. But, in my opinion, if you argue that < and > should be added in tandem as indexing operators you'd probably have a much steeper hill to climb.

@BreyerW
Copy link

BreyerW commented Jan 22, 2019

To me current symmetry is logical rather than mathematical . The thing is, accessing array is mostly based on math not logic. Due to this i foresee that subtracting or adding by one will be quite common due to this discrepancy while one of the minor motivations for this feature is to eliminate such bothersome quirks in as much places as humanly possible. E. g. imagine substracting equal amount of elements from start and end. With current implementation you MUST add by one on end and only end otherwise at best u get out of bounds exception (when substracting 0 elements) and at worst subtle bugs because end is off by one (when substracting more than 0 elements)

@HaloFour
Copy link
Contributor

@BreyerW

The primary motivation is to support slicing, in which case the math works pretty well:

var array = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
var slice = array[2..^2]; // { 3, 4, 5, 6, 7 }

And that's exactly how this works with languages that use negative indexing:

>>> list = (1, 2, 3, 4, 5, 6, 7, 8, 9)
>>> list[2:-2]
(3, 4, 5, 6, 7)

@CyrusNajmabadi
Copy link
Member

As I said elsewhere the index/subscript could have been defined

Yes. That is understood. As mentioned several times already, these alternatives were considered, debated, and decided upon based on a wealth of information and cases that demonstrated to the LDM that the current approach is preferable. This was also done with a strong look at the ecosystem out there and how this has worked out elsewhere.

Also, as noted several times already: nothing about this design is preventing complimentary indexing/ranging proposals from happening in the future. We picked this design knowing that it would be great for many cases, and intuitive for many, but also not great for some cases. That was going to happen as long as we only allowed a single indexing/ranging approach to start with.

The intent here is to have support for the most common and most valuable style, and then see in hte future if it's necessary to provide direct language support for hte less valuable style.

--

If you don't want to wait, you can easily add your own .Gleave extension method in the meantime that gives you the semantics you want.

@CyrusNajmabadi
Copy link
Member

@HaloFour - Understood. But can anyone explain what advantages the chosen approach has over my suggested one? I'd truly like to understand the reasoning here.

To me, the current approach is far more intuitive and consistent. It also fits with so many other languages out there. So it's much more advantageous to go with the current POR.

@xCyborg
Copy link

xCyborg commented Feb 19, 2019

I do think that the syntax that was settled on for this is poor and the lack of symmetry when accessing the "first" element and "last" element is horrible. I wonder if these would have been better:

var x = array[<3]; // rather than array[^3] - i.e. we're perceiving the array from right-to-left

then add support for this (while still supporting [3])

var x = array[>3]; // a way to write array[3] - i.e. we're perceiving the array from left-to-right

along with 0 always referring to lowest indexed element and highest indexed element depending on whether < (or, sadly, in reality ^) is used. This would enable developers to write code that uses both "directions" in a clearer manner if they so chose.

There may be good reasons why the team did it they way they did, but the lack of symmetry makes no sense to me and will no doubt lead to subtle bugs where code is using both kinds of subscripts (perhaps calculating those subscripts) to fiddle with arrays and the developer simply forgot that 0 is first and ^1 is last!

As I said elsewhere the index/subscript could have been defined as either the +ve offset from the "first" element or -ve offset from the "last" element. As it stands now ^X means "negative offset X from last element + 1".

Is it too late to change this?

I totally agree, besides : there is inconsistency between hat Index value in isolated vs Range context.

@CyrusNajmabadi
Copy link
Member

I totally agree, besides : there is inconsistency between hat Index value in isolated vs Range context.

how so? in both cases they should be making a System.Index instance in the same manner.

@xCyborg
Copy link

xCyborg commented Feb 20, 2019

I totally agree, besides : there is inconsistency between hat Index value in isolated vs Range context.

how so? in both cases they should be making a System.Index instance in the same manner.

Well:

Index i1 = 3;
Index i2 = ^2;
int[] list = {0, 1, 2, 3, 4, 5, 6, 7, 8};
var val1 = list[i1]; // equals 3
var val2 = list[i2]; // equals 7
var slice = list[i1..i2]; // equals { 3, 4, 5, 6 } NO 7!

@HaloFour
Copy link
Contributor

@xCyborg

This has already been explained. Indexes refer to the position between the elements and don't carry an implied directionality. So when you use an index as the end of a range it is exclusive of the next element after that index.

This behavior is consistent with other languages that support ranges and slicing with negative indexes:

>>> list = (0, 1, 2, 3, 4, 5, 6, 7, 8)
>>> list[-2]
7
>>> list[3:-2]
(3, 4, 5, 6)

@CyrusNajmabadi
Copy link
Member

@xCyborg There's no inconsistency there. In both cases i2 is the System.Index(2, fromEnd) value. For ranges, the right side is exclusive, and hte left side is inclusive. For a normal index, it's as if you're only supplying the left side and saying you want a length of 1. So this is consistent here.

@Korporal
Copy link
Author

@HaloFour

I fail to see the significance of "This behavior is consistent with other languages", sure these can serve as a basis, an impetus but C# is it's own language and striving to make it adopt or mimic other languages when there are potential improvements to be had by deviating from them strikes me as a backward thinking.

The disregard for symmetry is a mistake in my opinion and the coupling of inclusivity/exclusivity with the way "other languages do it" is not innovative.

I really believe that this is going to become seen as a badly implemented capability in years to come, please reconsider, clear the whiteboard and start again.

@HaloFour
Copy link
Contributor

@Korporal

I fail to see the significance of "This behavior is consistent with other languages", sure these can serve as a basis, an impetus but C# is it's own language and striving to make it adopt or mimic other languages when there are potential improvements to be had by deviating from them strikes me as a backward thinking.

Other languages serve as the precedent for how any given feature may be designed. When that design is repeated many times over by completely different teams for completely different languages it speaks to the validity of that design. This model fits well within C#, with the exception that C# cannot flip to negative indexing due to compatibility constraints. It doesn't remotely matter what operator is decided upon here, even if the team decided to drop ^ for something else, this is still how it will behave because this is how it makes the most sense to behave.

The disregard for symmetry is a mistake in my opinion and the coupling of inclusivity/exclusivity with the way "other languages do it" is not innovative.

This design does not disregard symmetry. The symmetry has been explained countless times already. You have this model of how indexing and slicing works in your head which is not congruent with reality.

I really believe that this is going to become seen as a badly implemented capability in years to come, please reconsider, clear the whiteboard and start again.

You're welcome to your opinion, but reality seems to disagree with you. You not liking something does not make it bad design.

@CyrusNajmabadi
Copy link
Member

I fail to see the significance of "This behavior is consistent with other languages", sure these can serve as a basis, an impetus but C# is it's own language and striving to make it adopt or mimic other languages when there are potential improvements to be had by deviating from them strikes me as a backward thinking.

The current design is felt to be the improved design. This was based on several investigations into the pros/cons of inclusive vs exclusive ranges. In practice, exclusive worked out far nicer and cleaner.

As i've also mentioned, nothing about hte current design precludes adding inclusive ranges in the future. however, that assessment will be done at a later point to see if it's really necessary or not. The belief is that exclusive is best to have first, and inclusive can be added later if appropriate.

is not innovative.

Being 'innovative' is a non-goal.

I really believe that this is going to become seen as a badly implemented capability in years to come, please reconsider, clear the whiteboard and start again.

The alternatives came with more problems in more cases. The cases have already been enumerated and assessed. No new data has appeared to change any thinking here.

@CyrusNajmabadi
Copy link
Member

The disregard for symmetry i

What disregard for symmetry? inclusive-start/exclusive-end ends up one of the most symmetrical approaches. I think there's an issue somewhere where this is all discussed. Maybe someone can link to it (or you can search for it and read through)?

@Korporal
Copy link
Author

Korporal commented Feb 20, 2019

Here are the basic concepts involved:

  • Directionality (left to right and right to left)
  • Inclusivity and exclusivity

Devising a symmetrical notation this is a key step, forget "other languages".

int array[] = {A,B,C,D,E,F,G,H,I};

// Directionality:

var X = array[->2]; // X becomes C, backward compatibility means that [->n] is the same as [n].
var X = array[2<-]; // X becomes G.

var X = array[2->]; // X becomes D.
var X = array[<-2]; // X becomes F.

// Inclusivity/Exclusivity

var inclusive_slice = array[->2..2<-]; // yields: C, D, E, F and G.

var exclusive_slice = array[2->..<-2]; // yields: D,E and F.

The suggested operators -> and <- denote directionality and their position relative to their operands denotes inclusivity and exclusivity.

We can then (intuitively) write:

// element 2 from the left including that element - through to - element 3 from the right excluding that element.

var some_slice = array[->2..<-3]; // yields: C, D and E.

@Korporal
Copy link
Author

Korporal commented Mar 29, 2019

@Korporal
None of the regulars here we're involved in that decision. The LDC made that decision, none of whom contributed to this discussion as far as I can see.

@YairHalberstadt - Perhaps but they implicitly supported and today defend the design else we'd surely see their objections expressed here would we not? Never forget the adage "The only thing necessary for the triumph of evil is that good men should do nothing."

@bigredd0087
Copy link

@popcatalin81

Be warned, several regulars here have presented that in their opinion the current design is not consistent. When someone else presents a logical argument as to why it is consistent these individuals react with hostility because their opinion is questioned.

@jnm2
Copy link
Contributor

jnm2 commented Mar 29, 2019

After finding the point between elements naturally described by [x] or [^x], is the existing convention of reading forward inherent to the single-item indexing syntax itself ([ and ]), or is the convention flipped if the index passed to the indexer is a from-end index (^)?

I see pros and cons to both. No matter which one you pick, you will have to do by-one corrections in a large set of scenarios. I'm not sure which set is larger, but don't be mistaken and think that one of these choices makes off-by-one go away.

Also, each way of thinking about it has a powerful mnemonic that will keep you on the right track once this is part of the language and you have to deal which whichever way it is.

For the language design team's current choice:

  • x means "skip x elements" (implies moving forward to read)
    ^x means "skip all but x" (implies moving forward to read)

If they change their minds:

  • x means "distance from start" (implies moving forward to read)
  • ^x means "distance from end" (implies moving backward to read)

I suspect I'll be doing less by-one math with the team's current choice because that's what I gather that their own conclusions were (from what I've read). But either way, I know I'll be able to emphasize the most useful mindset and make the most of it.
(Because of this, I'm not really invested in the outcome. I'm more invested in fending off FUD by showing how usable each alternative really is.)

@jnm2
Copy link
Contributor

jnm2 commented Mar 29, 2019

Another way to look at it which has been buried:

Zero-based indexing doesn't mean the first item is 0; it means that 0 is where that item starts and 1 is where it stops. 0.5 indicates that you've traveled halfway across the item. This isn't the counting intuition we learned as kids, but it's the only one that makes sense in the face of fractions. Beyond that consistency, it also immediately gets rid of having to remember to add and subtract 1 when measuring lengths.



hat



Don't think of it like a calendar; think of it like a tape measure.


0 means the first tick mark, having traveled across 0 characters from the beginning. ^0 means the last tick mark, having traveled across 0 characters from the end.

Then, 0..^0 takes the whole string. 0..1 collects a single character (into a string), just like str[0].
0 and 1 are not referring to characters; they are referring to tick marks between the characters.

Our current indexers imply n..(n+1) when we say str[n].
str[6] throws since 6..(6+1) is past the end of the string.

@agocke
Copy link
Member

agocke commented Mar 29, 2019

If you want to understand our decision-making process on making Range open on the end, you should probably read through the language design notes, especially https://github.com/dotnet/csharplang/blob/72a4daa8532e191858f9f887f4c8d280ec006bb4/meetings/2018/LDM-2018-02-14.md

@Korporal
Copy link
Author

Korporal commented Mar 29, 2019

Another way to look at it which has been buried:

Zero-based indexing doesn't mean the first item is 0; it means that 0 is where that item starts and 1 is where it stops. 0.5 indicates that you've traveled halfway across the item. This isn't the counting intuition we learned as kids, but it's the only one that makes sense in the face of fractions. Beyond that consistency, it also immediately gets rid of having to remember to add and subtract 1 when measuring lengths.

hat

Don't think of it like a calendar; think of it like a tape measure.

0 means the first tick mark, having traveled across 0 characters from the beginning. ^0 means the last tick mark, having traveled across 0 characters from the end.
Then, 0..^0 takes the whole string. 0..1 collects a single character (into a string), just like str[0].
0 and 1 are not referring to characters; they are referring to tick marks between the characters.
Our current indexers imply n..(n+1) when we say str[n].
str[6] throws since 6..(6+1) is past the end of the string.

@jnm2 - I think the diagram is fundamentally flawed. The integers should sit beneath the cells not the left hand boundary lines, it's the cells (the individual bytes of the byte addressable memory) that are numbered not the implied "lines" between them.

@HaloFour
Copy link
Contributor

@Korporal

I think the diagram is fundamentally flawed. The integers should sit beneath the cells not the left hand boundary lines, it's the cells (the individual bytes of the byte addressable memory) that are numbered not the implied "lines" between them.

Effectively it would be the same thing. 5 and ^1 would still index the same element, and both 6 and ^0 would be out of range.

@Korporal
Copy link
Author

@Korporal

I think the diagram is fundamentally flawed. The integers should sit beneath the cells not the left hand boundary lines, it's the cells (the individual bytes of the byte addressable memory) that are numbered not the implied "lines" between them.

Effectively it would be the same thing. 5 and ^1 would still index the same element, and both 6 and ^0 would be out of range.

@HaloFour - But the diagram is flawed and does not correctly represent the problem, as soon as we begin to tolerate an inaccuracy like this it's effects begin to contaminate the solution.

@CyrusNajmabadi
Copy link
Member

@HaloFour - But the diagram is flawed

The diagram is flawed for you. This conversation has happened numerous times now. It's your opinion and it's been heard. But it hasn't been accepted by others. Without a sufficient argument as to why it's more appropraite to see things your way, nothing is going to change here.

@Korporal
Copy link
Author

@HaloFour - But the diagram is flawed

The diagram is flawed for you.

@CyrusNajmabadi - The diagram is flawed period because it numbers the bondaries between cells rather than the cells, no wonder you have trouble understanding when people express objections here.

This conversation has happened numerous times now. It's your opinion and it's been heard. But it hasn't been accepted by others. Without a sufficient argument as to why it's more appropraite to see things your way, nothing is going to change here.

Are you referring to my opinion about the diagram or the implementation of this index feature? please express yourself accurately if you want to engage in a meaningful technical discussion with me.

If you are referring to my views on the implementation then you must be corrected when you assert "It's your opinion and it's been heard. But it hasn't been accepted by others." because even a cursory reading of this issue will show you there are several other people expressing criticisms of how this has been implemented, if you took the trouble to remain objective you'd have noticed this rather than emotionally focusing only on what I say.

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi - The diagram is flawed period because it numbers the bondaries between cells rather than the cells, no wonder you have trouble understanding when people express objections here.

You are stating what it does, not why it is flawed. Others (including myself) do not feel there is any flaw with this sort of representation of the data/logic involved. Indeed, this is how i've been taught and have taught others. It's a very sensible way of understanding ranged operations. For example, when reading a segment of an array, one often is given a starting position and a length. These representations make it very clear waht's happening. The approach that has hte numbers under the slots makes it a lot less clear. Are reads happenign past that point or starting at that point? What does a 0 read length mean if the index selects the whole item? etc. etc.

If you are referring to my views on the implementation then you must be corrected when you assert "It's your opinion and it's been heard. But it hasn't been accepted by others." because even a cursory reading of this issue will show you there are several other people expressing criticisms of how this has been implemented,

yes. Your opinion has been heard. It is not agreed with. I'm not sure what you want or expect at this point. Continually harping that you don't like this formalization, while not providing adequate justification, won't get you anywhere.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Mar 29, 2019

no wonder you have trouble understanding when people express objections here.

I have no trouble understanding. I'm simply stating that your objection has been heard and understood. But that it has also been rejected. The formalization around this has been discussed at length and the pros and cons of it are well understood (especially in relation to the formalization you want). The options were considered and this was felt to be the best approach with full knowledge of all the pros/cons that have since been listed and repeated ad-nauseam.

If you don't have anything further to add to the discussion, then simply reiterating that you don't like this formalization and prefer your own, won't get anywhere.

--

Note: one thing i did to help out here was to try to use both forms. I did a bunch of work using these alternative approaches working with strings, arrays, file buffers, and several Roslyn data types. By far, the easiest and most intuitive to wrap my head around was the [inclusive/exclusive) form. There were a couple of cases where it was slightly worse. But those were the rare cases.

This investigation was also done by several people working with the Range/Index proposal. And it was their great work at actually investigating many domains that helped push nearly the entire LDM (possibly the entire LDM, but i don't really recall at this point) to feel that this form was the better of the two to have by default.

@jnm2
Copy link
Contributor

jnm2 commented Mar 29, 2019

@Korporal Saying the diagram is flawed is begging the question. Maybe it's flawed, if the only way to see things is from a single point of view. The diagram is really good at making the C# team's point of view more intuitive.

It's coming across as though you've prejudged the issue and aren't honestly trying to see things from any other point of view. Which is fine, but everyone can sense that you're doing this and practically speaking it's not a convincing maneuver. Neither is combativeness or aggressive choice of words. You may feel they are justified, but even if they are they're working directly against your ability to make a difference, so you decide.

@Korporal
Copy link
Author

@jnm2

@Korporal Saying the diagram is flawed is begging the question. Maybe it's flawed, if the only way to see things is from a single point of view. The diagram is really good at making the C# team's point of view more intuitive.

How can saying the diagram is flawed be begging a question? it's either an accurate depiction of cells and how they're numbered or it isn't, why the reluctance to see the obvious here? If you think a sloppy inaccurate diagram is a sound basis upon which to have a technical discussion then that's fine but I don't work that way.

It's coming across as though you've prejudged the issue and aren't honestly trying to see things from any other point of view. Which is fine, but everyone can sense that you're doing this and practically speaking it's not a convincing maneuver. Neither is combativeness or aggressive choice of words. You may feel they are justified, but they're working directly against your ability to make a difference, so you decide.

You say all that just because I regard the diagram to be poor? Then you claim to know what "everyone" is able to "sense" whatever that means!

There is no aggression in anything I've posted and I resent you saying otherwise, I disagree on several points with respect to this language feature and as I've just said to someone else I am far from being alone in my criticisms.

Please stick to the subject and lets have less strawman posts please.

@CyrusNajmabadi
Copy link
Member

How can saying the diagram is flawed be begging a question?

You're using your premise to support yourself. But your premise has not been established as being true. It's just a claim on your part.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Mar 29, 2019

it's either an accurate depiction of cells and how they're numbered or it isn't

To many people here, it's accurate. It's certainly accurate to me, and it's a long established way of thinking about how data is laid out and how indexing and ranges work. It's not like this suddenly popped into existence in this thread.

If you think a sloppy inaccurate diagram

Begging the question again.

I disagree on several points with respect to this language feature

Your disagreement has been heard and evaluated. It was assessed against the other arguments made for the feature as is, along with the empirical evidence about the pros/cons of all the possible options present. It was rejected as providing a less intuitive and understandable model, as well as providing a system that was less easy to use in practice across a wide set of APIs.

Absent anything new you can add to help support your argument, nothing about your dislike of the existing POR will change anything.

@theunrepentantgeek
Copy link

theunrepentantgeek commented Mar 29, 2019

@Korporal wrote:

There is no aggression in anything I've posted

The primary limitation of a forum like this is that we have only the written text to interpret. It's a low bandwidth medium. We don't get any additional information from tone of voice, body posture, pace of delivery, facial expression, etc. Add in the fact that different people use the English language in markedly different ways, and it becomes really easy for miscommunication to occur.

Hugh, I'm totally willing to believe that you read your words and don't see them as aggressive.

Sitting here, on my Saturday morning, most likely halfway around the world from you - because New Zealand is halfway around the world from most everywhere ... you do come across to me across as aggressive. Very much so.

That said, I have no doubt that we'd have a great deal of fun debating language design issues over a quiet drink or two, should the opportunity occur.

@jnm2
Copy link
Contributor

jnm2 commented Mar 29, 2019

@Korporal What am I supposed to do with anything you just said? I'm trying to reach out and find middle ground, and you've just taken the opportunity to be rude to me again. Instead of giving an argument, you're sticking to flat contradictions and calling my example sloppy and inaccurate. What would you do if someone replied to everything you said by directly contradicting it, claiming to see a straw man in your argument, and finding a few degrading things to say about you?

I'm at a loss. The most reasonable thing I can think of right now, after this final appeal to your humanity, is for me to stop participating in this thread. I mean, what else can I do at this point? You win the stubbornness game, congrats! Nothing has been accomplished.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Mar 29, 2019

There is no aggression in anything I've posted and I resent you saying otherwise,

The important thing to realize is that you have the ability to affect how others read your words. I've certainly not meant to be aggressive in the past, but it's been read that way by others. That's on me when, on the whole, that is the interpretation of many have come to the same interpretation.

In this case, you've come across extremely aggressive. You seem to have flat out been unwilling to come to any sort of understanding of positions different from your own, and you seem to have rejected the idea that your position has been considered but was overruled based on a careful analysis of hte information as well as empirical studies of hte ecosystem. Because you have been unwilling to try to reach any sort of common ground, and because you seem to just flat out reject different points of view, you come across extremely aggressive.

You may not intend that. But it's certainly how it's been coming across to me for nearly your entire conduct in this thread.

@Korporal
Copy link
Author

Korporal commented Mar 29, 2019

@Korporal wrote:

There is no aggression in anything I've posted

The primary limitation of a forum like this is that we have only the written text to interpret. It's a low bandwidth medium. We don't get any additional information from tone of voice, body posture, pace of delivery, facial expression, etc. Add in the fact that different people use the English language in markedly different ways, and it becomes really easy for miscommunication to occur.

Hugh, I'm totally willing to believe that you read your words and don't see them as aggressive.

Sitting here, on my Saturday morning, most likely halfway around the world from you - because New Zealand is halfway around the world from most everywhere ... you do come across to me across as aggressive. Very much so.

That said, I have no doubt that we'd have a great deal of fun debating language design issues over a quiet drink or two, should the opportunity occur.

@theunrepentantgeek - Please quote me then, don't paraphrase - is this request too something you'd regard as aggressive?

Bevan you accuse me of being aggressive yet fail to actually quote an example of such from one of my posts. Perhaps you regard the act of disagreeing and arguing one's case as being aggressive...

Anyway I have work to do and the pettiness I'm seeing here is almost juvenile, have fun guys.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Mar 29, 2019

Anyway I have work to do and the pettiness I'm seeing here is almost juvenile, have fun guys.

That's an example of aggressiveness, and not being willing to work toward a common ground or understanding.

Here are other examples:

Be warned, several regulars here react with hostility when their collective decision making is questioned. We - the great unwashed - are simply not worthy to question these gifted individuals.

The diagram is flawed period ... no wonder you have trouble understanding

why the reluctance to see the obvious here? If you think a sloppy inaccurate diagram is a sound basis upon which to have a technical discussion then that's fine but I don't work that way.

Honestly, 'aggressive' is putting it mildly. You're just not behaving in a manner that makes anyone want to converse with you.

@Korporal
Copy link
Author

@CyrusNajmabadi - You clearly don't know what aggression is Cyrus, you must be of a rather delicate constitution if my words cause you that much angst.

Now here's an idea rather than repeatedly whining about my posts here and the effrontery you perceive when someone disagrees with you and is unimpressed with your responses, why not simply stick to the subject at hand.

Here's my take 1) The diagram is sloppy and that needs to be said and 2) the way this language feature has been implemented will go down in history as a poor design, of that I'm sure. If people can't even depict the mechanism accurately in diagrams how can we expect the ensuing designs to be sound?

@CyrusNajmabadi
Copy link
Member

Cyrus, you must be of a rather delicate constitution if my words cause you that much angst.

This is another aggressive and unnecessary statement.

Now here's an idea rather than repeatedly whining about my posts here and the effrontery you perceive when someone disagrees with you and is unimpressed with your responses, why not simply stick to the subject at hand.

Because your behavior and attitude makes it so that people do not want to converse with you on this topic. If you are unwilling to do anything about that, then no progress can be made at all since any relevant parties will simply no longer respond to you.

Here's my take 1) The diagram is sloppy and that needs to be said

Yes, as stated before, your opinion here has been gathered, it just isn't something that is agreed with.

the way this language feature has been implemented will go down in history as a poor design, of that I'm sure.

Thanks for letting us know. That's a risk people are willing to take.

If people can't even depict the mechanism accurately in diagrams

The mechanism seems easy to depict in diagrams. You happen to not like the diagram, but that doesn't mean it's not simple to represent and explain.

@HaloFour
Copy link
Contributor

Yes, everyone will be incredibly confused when C# happens to work the same way as every other language.

@Korporal
Copy link
Author

@CyrusNajmabadi

Anyway I have work to do and the pettiness I'm seeing here is almost juvenile, have fun guys.

That's an example of aggressiveness, and not being willing to work toward a common ground or understanding.

It's helpful to review the definition of the term (you chose to use) "aggressiveness"

"Aggressiveness is rarely malicious or violent. Instead, the word connotes assertiveness and drive—a more figurative aggression. It is more of an attitude, and it may even be viewed as a positive character attribute in the workplace or on a sports field, for instance. Aggression involves behaviors that would not be considered acceptable in these settings." [emphasis mine]

From here. so thank you for the compliment.

I'm done in this thread now.

@CyrusNajmabadi
Copy link
Member

why not simply stick to the subject at hand.

Every point about your position has already been addressed. You yourself have admitted it simply comes down to opinion about where you land on the right way to interpret things (i.e. Here's my take 1) The diagram is sloppy). So what else is there to say? Your position has not convinced people.

@CyrusNajmabadi
Copy link
Member

I'm done in this thread now.

Thanks. I think removal from the thread will definitely help keep things more civil and on topic. I appreciate you seeing that and being willing to bow out.

@agocke
Copy link
Member

agocke commented Mar 29, 2019

I think the original question has been answered and the rational of why we chose the current design has been linked, so I'm closing this issue.

@agocke agocke closed this as completed Mar 29, 2019
@dotnet dotnet locked as resolved and limited conversation to collaborators Apr 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests