C# Needs Seqs

added by KodefuGuru
2/8/2012 11:42:20 AM


A proposition for a new keyword in C# to support IEnumberable<T>.


2/8/2012 11:47:57 AM
So rather than writing IEnumerable(t) we write seq(t), or is seq(t) in addition to IEnumerable(t)?
Sequence implies that there's an order, but being IEnumerable(t) means that there isn't a particular order unless we specify how it's sorted (being that the types are generic).
A set, however, doesn't imply order, so maybe it could be set(t)?

2/8/2012 11:57:33 AM
I propose seq as an alias keyword, like string is an alias for System.String.

I'm going to write an article on sequences versus sets, because I was thrown when someone else brought it up. In a sequence, order matters. This means a sequence is unique if an element differs from the comparison sequence at any position. In a set, order doesn't matter. A lottery ticket is a set. The konami code is a sequence.

Here's another way to look at it
a = 1, 2, 3
b = 3, 2, 1

If a and b are sets, they are identical. If a and b are sequences, they are different. So, the difference between a set and a sequence is that order matters for the latter. But there's more! Sets must contain unique values. {1, 1, 2, 3} is the same as {1, 2, 3}, because 1 is merely repeated in the former's definition.

I think it's pretty clear that we're referring to a sequence with IEnumerable<T>. Using that term would maintain consistency with other languages as well.

2/8/2012 11:59:56 AM
Thanks for following up, that makes sense. I didn't think about the issue of uniqueness with sets.