On Fri, 2011-10-07 at 08:49 +0200, Jacob Carlborg wrote: [ . . . ] > I think it's important to support the range interface (or if it's > simpler, the array interface). I think ActiveRecord has a good high > level API which allows to lazily evaluate SQL queries. > > persons = Person.all # no query is performed here > persons = persons.where("name = 'Joe'") # or here > > persons.each do |p| # The actual query is performed here > # do something with each Person > end > > I don't think it would be strange to see something like this: > > Person.where("age > 10").map{ |p| p.name } # using "map" on an SQL query
Not just Ruby an Rails with ActiveRecord. Groovy/Grails/GORM does what is basically the same. Python cannot do the same in the same way Ruby and Groovy can, but it has it equivalent (augmented with SQLAlchemy). Basically it comes down to constructing dynamic queries using the dynamic and MOP nature of the languages. The crucial keyword here is Builder. The trick is that what looks like function call is actually interpreted via the builder/MOP as the construction of a data structure, which then creates the query on demand -- with template placeholder filling as required. Does D have the reflection capabilities to do this in any way, shape or form similar tp the way the dynamic languages do it? -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part