AST macros

Sean Kelly sean at f4.ca
Mon Mar 19 23:04:13 PDT 2007


Daniel Keep wrote:
> 
> David B. Held wrote:
>> Daniel Keep wrote:
>>> Walter,
>>>
>>> I've just been going back over my old (and now fairly crusty) coroutine
>>> implementation, and realised that macros could make these a *major*
>>> feature of D.
>>>
>>> Ideally, I'd like to see a syntax like this:
>>>
>>>> coro showfiles(char[] msg)(char[], char[]) // <-- input,output types
>>>> {
>>>>     char[] path;
>>>>     while( (path = yield) != null ) // <-- yield is a protected method
>>>>     {
>>>>         writefln("%s: %s", msg, path);
>>>>     }
>>>> }
>>> [...]
>> I thought Tango had Fibers?
>>
>> Dave
> 
> Cooperative multithreading does not a coroutine make.  Fibers, IIRC, are
> just stack-based threads.  Coroutines are *entirely different*, although
> in this particular case they are implemented *using* stack threads.
> 
> In any case, I have a working library right now... it's just that the
> syntax to use them is rather ugly and a bit messy.

For what it's worth, Mikola Lysenko has coroutines as a part of his 
StackThreads implementation, and it should be pretty easy to adapt them 
to use Tango's Fibers.  The page is here: 
http://www.assertfalse.com/projects.shtml


Sean



More information about the Digitalmars-d mailing list