Internal and external iteration, fibers

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Sun Jan 20 12:19:55 PST 2013


On Sun, 20 Jan 2013 03:45:00 +0100
Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 01/19/2013 10:46 PM, Nick Sabalausky wrote:
> > On Sat, 19 Jan 2013 09:45:25 +0100
> > "qznc" <qznc at go.to> wrote:
> >
> >> On Friday, 18 January 2013 at 17:59:36 UTC, Nick Sabalausky wrote:
> >>> Then there's C/C++ which has libs that offer what are known as
> >>> "stackless fibers". These utilize the preprocessor, along with
> >>> switch
> >>> and goto, to accomplish the same thing that (AIUI) C# does for
> >>> its
> >>> coroutines: It lets the user write a normal coroutine, with a
> >>> normal
> >>> yield, which then gets trivially rewritten behind-the-scenes
> >>> into an
> >>> event loop (with NO actual fibers involved). I'm not sure to
> >>> what
> >>> extent this would be possible in D. If it is, the lack of
> >>> preprocessor
> >>> would probably make it much less nice-looking to use than the
> >>> C/C++/C#
> >>> versions. (Not that I'd want a preprocessor.)
> >>
> >> Is this also known as protothreads?
> >>
> >> http://dunkels.com/adam/pt/
> >
> > Yea. In fact, that's the exact same lib I've used.
> >
> 
> This can be implemented a lot better looking in D. (My quick hack 
> already looks better.) But I think we should first build a 
> general-purpose DSEL library.

If we need to resort to using D-as-a-DSL-inside-D to get decent
coroutines, then that just further proves the need for a real coroutine
support in the language.




More information about the Digitalmars-d mailing list