On Monday, 18 May 2015 at 09:12:50 UTC, Per Nordlöw wrote:
On Monday, 18 May 2015 at 08:44:30 UTC, Per Nordlöw wrote:
On Tuesday, 12 May 2015 at 00:42:28 UTC, Ali Çehreli wrote:

When will the video be available online?

A key follow-up question:

Is there any significant space- and time-overhead in being lazy and choosing a fiber-based solution to convert a function to a range instead of converting it to a standard D range?

One caveat with D fiber implementation is that in the following example

import std.stdio;

import std.concurrency: yield;

void fibonacciSeries()
    int current = 0; // <-- Not a parameter anymore
    int next = 1;
    while (true)
        current.yield; // return
        const nextNext = current + next;
        current = next;
        next = nextNext;

    import std.concurrency: yield, Generator;
    auto series = new Generator!int(&fibonacciSeries);
    import std.range: take;
    writefln("%(%s, %)", series.take(10));

the type of `current` and template argument to `Generator` must manually match. Isn't it possible to design a D api that matches these at compile-time?

Otherwise we risk getting run-time exceptions such as

object.Exception@/home/per/opt/x86_64-unknown-linux-gnu/dmd/linux/bin64/src/phobos/std/concurrency.d(1694): yield(T) called with no active generator for the supplied type

Could yet another function qualifier (or extended attribute) do the job of checking this at compile time?

Reply via email to