-
Notifications
You must be signed in to change notification settings - Fork 3
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
ISequence naming #1
Comments
Ordering is a bit of an ambiguous term, I consider it ordered but not sorted. The ordering is determined by construction. If an item is added (appended), then it will always be returned as the last item. I'm using the term Sequence synonymously with Enumerable, but with the constraint that the first item is always the first item, and the last item is always the last item. Unfortunately with an IEnumerable is that it can change between invocations on the same data set. The name is inspired by https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/sequences. I always found "enumerable" to be a bit of an obtuse academic term. |
But if it's potentially infinite, how can you have an order beyond time? Can you have a concept of First or Last? I'm thinking of the example: Is ISequence as a name compatible with the common formal usage? https://en.wikipedia.org/wiki/Sequence |
In the Wikipedia article they do mention that a sequence can be infinite. Consider the sequence: "1,0,1,0,...". There is a first item, but indeed there is no last, which is the same problem as IEnumerable. It is a good to note that any concept of infinite series, should be careful about introducing potentially undefined operations (like "ToArray()", "Last()", "TakeLastN()", "Reverse()"). I generally consider this a design mistake, but I decided to keep operation naming a 1-to-1 with LINQ, to facilitate cross-over. Plato should be a drop-in replacement for any C# programmer, with a minimal learning curve. They just have to get used to pure functional programming. Other inspirations for the name "Sequence" come from Scala (https://www.scala-lang.org/api/2.12.x/scala/collection/Seq.html), and was also used in Clojure (https://clojure.org/reference/sequences).
You have the order in which it was add to the sequence during construction.
The idea of something being truly unordered is extremely rare in practice in programming. A Plato ISet is one example of this. You can ask whether something is in a set, you can create a set by combining or interesecting them. You can even take the true complement of a set (create the set of all things not in the set), which is not possible with IEnumerable. To make this possible, there has to be no operations that imply ordering. You simply cannot say "Get me the first item of a set". It makes no sense mathematically. I also had a bag concept, but over the last week (and through our conversations) realized that it wasn't very useful practically, and I'll be removing it. |
There's nothing wrong with a Bag (MultiSet). While the use cases are uncommon they are not rare I'd say. I could represent the items in a Shopping Cart for instance. The order doesn't matter and I can have the same item multiple times. I also don't have to assume every item has a SKU number or some other common ID scheme. |
ISequence<T>
implies an ordering which is not your intention I believe. Perhaps call itIStream<T>
?The text was updated successfully, but these errors were encountered: