I've thought about this as well. Coming from the .NET world I'm quite familiar with the Linq.Expression namespace. I too have wondered about this. For those who are not familiar with how IQueryable<T> works in Linq, it's something like the following (in clojure):
(def query (q (db :people) (where #(> (:age %) 21)) :last-name distinct)) The (db :people) call will return a IQueryable object. The q macro will then take all the clauses in the query, wrap them up into an AST, and then create a lazy seq. At this point in the code, nothing has been executed. Upon calling (first query), the q macro hands the AST to the IQueryable object, and then calls Execute on the object. Execute does whatever it pleases with the AST, and then returns a lazy seq of the results. A C# tutorial on this, is available here ( http://wekeroad.com/2007/07/02/linq-how-to-use-linq-to-query-just-about-anything/ ) I see this fitting into the Clojure ecosystem in a very interesting way: Seq abstraction - Lazy evaluation Must run on the local CPU (for map, reduce, etc.) Must run in order Data provider can't influence execution Reducers - Data provider can influence execution Must run on the local CPU Can run in any order IQueryable abstraction - Data provider has full control over execution Code can be run anywhere Provider must compile code. Example providers of IQueryable: Entity Framework (Linq over SQL) Linq to XML (Linq over XML) Linq to GPU (run queries on a graphics processor) http://brahma.ananthonline.net/ I've also seen index providers for in-memory data structures So, I guess the original question still remains. Would Clojure benefit from an AST abstraction? I know we have macros, but is that enough? I'd love input on this topic. Timothy Baldridge -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en