D talk at Silicon Valley ACCU

via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon May 18 13:08:27 PDT 2015


On Monday, 18 May 2015 at 18:35:04 UTC, Ali Çehreli wrote:
> converted to a static assert. Still though, there is no 
> guarantee that "int" matches what is yielded.

Couldn't `yield()` capture CT-attributes of the calling function, 
in this case `fibonacciSeries`, and propagate them via default 
values of template arguments like is done in, for instance,

void contextual_writeln(string file = __FILE__,
                         uint line = __LINE__,
                         string fun = __FUNCTION__, T...)(T t)
{
     import std.stdio: writeln;
     try { writeln(file, ":",line, ":"/* , ": in ",fun */, " 
debug: ", t); }
     catch (Exception) { }
}

and use them to match the type of the argument to yield at 
compile-time? AFAIK everything visible by the compiler such UDA 
of functions could be put in a template argument either as a 
template alias or string parameter.

If not, isn't it time for a specific keyword for spawning threads 
and/or fibers? Contentenders could be `yield`, `go`, `co`, 
`spawn`. I'm aware of the problem with new keywords conflicting 
with existing symbols but that could be solved with deprecation 
phase so people can fix their code.


More information about the Digitalmars-d-announce mailing list