4 ms·
I know it will never happen, but something like LINQ in C#. Not just functions that iterate over collections, but the whole idea of language integrated queries
by scarface74 8y ago
I know it will never happen, but something like LINQ in C#. Not just functions that iterate over collections, but the whole idea of language integrated queries where code is turned into expression trees that can be parsed and translated by providers.
For instance in C# you can take the same LINQ expressions and they can be translated to sql by EF or MongoQuery by the Mongo driver at runtime.
- kristiandupont 8y agoWithout type safety, there doesn't seem to be much to gain from this besides for a bit of syntax checking?
- scarface74 8y agoIn this case of LINQ, I can call methods like: var retiredMales = custRepo.Find(c => c.Age > 65 and c.Sex == “M”) and then have an interface with a member: List<Customer> Find(Expression<Func<Customer,bool>> expression): You can implement three classes for that interface - one that uses EF, one that uses Mongo, and one that just uses in an memory List for unit testing and they all translate the expression to the underlying data store. Theoretically, you could have an “expression” type in JS that can be parsed by the provider.
- jauco 8y agoWhat you’re looking for is the backtick in lisp. Or more generally: lisp macro’s where a function can inspect the ast of an argument and base it’s result on that. For those who gave never used linq: this allows the above function to translate the function to a sql, sparql or mongo query depending on the currently selected backend