Internal and external iteration, fibers
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Mon Jan 21 11:00:25 PST 2013
On Mon, 21 Jan 2013 11:48:58 +0100
"deadalnix" <deadalnix at gmail.com> wrote:
> On Monday, 21 January 2013 at 09:18:34 UTC, Timon Gehr wrote:
> > On 01/21/2013 10:08 AM, deadalnix wrote:
> >> On Monday, 21 January 2013 at 08:27:28 UTC, Nick Sabalausky
> >> wrote:
> >>> Stackless "fibers": Requires gross syntactical contortions
> >>> much like
> >>> opApply does.
> >>
> >> Can you explain more what a stackless fiber is ? From the
> >> linked posted
> >> above I did really understood, as the example code clearly call
> >> functions, which require stack.
> >
> > A stackless fiber does not have the execution stack as part of
> > its context. (Therefore it cannot yield from nested function
> > calls.)
>
> Ho yeah, I looked at the implementation. It is mostly made of
> macro that create a function with a big switch in it.
>
> Why can't this be done in D ? What are the major problems ?
I don't know whether or not it can be done in D. But, if it can be
done, it would definitely require awkward syntax. Probably more awkward
than the preprocessor-based syntax of the C/C++ version. (Not that I
want a preprocessor in D.)
Maybe you could do it by sticking the whole coroutine into a string
literal that gets ripped apart and reassembled by a CTFE D parser, but
that would just be so clumsy and error-prone, and frankly far more
complex than should really be necessary, that I'd call it more of a
kludge than a solution. And really, if I have to write D code inside a
string literal to use it, that alone indicates that we're looking down
the wrong path.
More information about the Digitalmars-d
mailing list