As I understand it IEnumerable and IQueryable are deferred execution. Why wouldn’t it be of benefit for IList to also support deferred execution?
As I understand it IEnumerable and IQueryable are deferred execution. Why wouldn’t it be
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The longer I think about it, the more I question whether the whole idea of “deferred execution” is actually of pedagogic value at all.
I’ll answer your question by denying it.
IEnumerable<T>,IQueryable<T>andIList<T>do not in any way represent “deferred” or “eager” calculations.Rather, interfaces represent an ability to provide a service.
IEnumerable<T>represents the service “I can provide a sequence, possibly infinite, of items of type T, one at a time”.IQueryable<T>represents the service “I can represent a query against a data source, and provide the results of that query on demand”.IList<T>represents the service “I can provide random access to a possibly mutable, finite-sized list of items of type T”.None of those services say anything about the implementation details of the service providers. The provider of an
IList<T>service could be entirely lazy; the provider of anIQueryable<T>service could be entirely eager. If you want to make a deferred-executionIList<T>, you go right ahead. No one is stopping you!