On 02/09/2018 08:53 AM, Seb wrote:
On Friday, 9 February 2018 at 13:10:16 UTC, rumbu wrote:
I'm missing too the yield return and await syntax in D every time.
What's wrong with the library solution from std.concurrency?
I can't speak for await, as I left C# for D long before it was introduced.
But as far as yield return (ie, C#'s coroutines): The problem with the
std.concurrency version is that it introduces the overhead of fibers and
context-switching. Sometimes that's ok (network/file i/o), sometimes
it's not (parsing). (You *can* switch to foreach/apply to do it, but
then you lose the ability to offer a range-based interface...unless you
But the C# version, OTOH, lacks this fiber overhead entirely:
Internally, it works the same way as C's protothreads
<http://dunkels.com/adam/pt/>, but with far nicer syntax.
- no dedicated syntax sugar for ranges;
What do you expect here?
(also it's not entirely true - foreach already supports ranges)
For input ranges (maybe even forward ranges), a stackless corountine
approach like C#.
But even for all-out random-access, defining them is quite boiler-plate
heavy (by D standards anyway) and could really use some sugar. Exactly
what that sugar would be like, I don't know, but it could definitely use
- no dedicated syntax sugar for coroutines;
What syntax sugar that can't be done by a library do you expect?
Doing it without the overhead of fibers. This requires either a C-style
preprocesser (yuck, and note string mixins aren't sufficient here) or
lowering. (I guess if we had AST macros, maybe we could do this lowering
in the library, but we don't.)