Robert Jacques wrote:
On Mon, 12 Oct 2009 21:45:20 -0400, Michel Fortin
<michel.for...@michelf.com> wrote:
On 2009-10-12 11:45:55 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:
Occasionally people here ask for ways in which they can help D. One
thing that would be extremely helpful at this point would be to help
defining and implementing D's new concurrency API. Unfortunately,
Bartosz has declined to contribute. That leaves Walter, Sean, Don,
and participants to this group to do it.
So Bartosz quit? Not that much surprising given the all too many
missing building blocks.
I recently realized that you can easily implement unique in a library.
It can work pretty much the same as auto_ptr in C++. But to guaranty
uniqueness you need either to rely on convention (as in C++), or add
support for lent to the compiler.
I know we discussed at length how lent could be implemented, we called
it 'scope' and 'escape analysis' at the time and the conclusion you
(and Walter I guess) came with was that it was too much for D2.
Well, without lent (and thus without unique), safe message passing
systems across threads will be limited to immutable data, or copied
data, which not at all useful in many situations.
Now if you want a good concurrency API relying on convention, then
that's great: there are plenty of examples to follow out there. But if
you want it to be both safe (enforced) and useful at the same time,
that's a mission impossible with the current set of tools available
from the compiler.
That's why I'm not surprised Bartosz declined to implement it.
(And sorry if I sound pessimistic.)
I agree. Particularly about lent. Immutable and mutable weren't
considered complete without const, so I'm surprised that local and
shared are considered complete without lent. You can even implement it
without escape analysis. Strangely, from what I remember of Bartosz's
posts, it was unique that was the sticking point, though you can
implement both unique and owned as library types (though they do become
less efficient).
I may sound ignorant, but that does lent means? I mean the word itself,
I couldn't find something relevant on google.
Anyways, I agree that we need a type qualifier between unshared (local)
and shared, just like const sits between mutable and immutable. It would
make shared handling just so much easier and convenient.
If shared/lent were properly implemented and as easy to use as
immutable/const, we'd already begin to see concurrency APIs, I tried a
few times to implement different concurrency models and always failed
due to shared requiring either too much casts or forces too many
structures and methods to be shared.
I vote for a 'lent' qualifier to be implemented in the compiler.
Jeremie