Working functionally with third party libraries

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 18 01:03:54 PDT 2015


On Friday, 17 July 2015 at 12:59:24 UTC, Kagamin wrote:
> On Friday, 17 July 2015 at 09:07:29 UTC, Jarl André Hübenthal 
> wrote:
>> Or loop it. But its pretty nice to know that there is laziness 
>> in D, but when I query mongo I expect all docs to be 
>> retrieved, since there are no paging in the underlying 
>> queries? Thus, having a lazy functionality on top of non lazy 
>> db queries seem a bit off dont you think?
>
> From the client point of view db is sort of lazy: data is 
> received from server as needed. Why would you want to put all 
> data into an array before processing it? Why can't you process 
> it from the range directly?

Its simple. In most cases you do an advanced aggregated search in 
mongo, and what you get is then a mongocursor. Lets say I am 
retrieving all projects for a given customer where the project is 
started.. I really am in no interest of lazily evaluating this 
result, because I want to return this data to the client 
(browser) immediately. And lets say I am in a prototype phase 
where i haven't yet implemented all those nasty mongo queries, I 
want to be able to filter, map and reduce the result and work 
with arrays not some sort of non evaluated lazy MapResult. In 
scala luckily I have implicit converts, so that I can just stop 
thinking about it and have it converted automatically.


More information about the Digitalmars-d-learn mailing list