On the richness of C++
Walter Bright
newshound1 at digitalmars.com
Tue Apr 15 17:05:02 PDT 2008
Jason House wrote:
> Walter Bright wrote:
>
>> Jason House wrote:
>>> I'd love to see some kind of page comparing D with the contents of
>>> Modern C++ Design. It'd be a good selling point for D when the
>>> hoards of disgruntled C++ programmers start looking at D. I wonder
>>> what could be done within copy right restrictions...
>> If you want to write such a page, I'm sure Andrei would be willing to
>> discuss it with you.
>
> That'd be a nice exercise in learning to stress D :) I'm assuming Andrei
> won't read and reply to this post, so what would be the next step forward?
You can contact Andrei via his web site http://erdani.org/
>>> Closures capture variables by reference. This means that creating
>>> delegates inside a foreach loop (with deferred evaluation) could fail
>>> to have the expected behavior. Bind stores stuff by value, so I
>>> still find myself using bind libraries.
>> If you expect captured variables to be by value, sure. But I always
>> expected them to be by reference!
>
> By reference is nice in many cases, but in others it's frustrating. How do
> you implement the following?
>
> foreach(job; queue)
> runthread(void delegate(){job.execute;});
>
> (Somehow I expect someone to pick apart the example, but I hope the point is
> clear)
No, the point isn't clear. Closures can handle multiple threads
accessing it.
More information about the Digitalmars-d
mailing list