AST macros
Daniel Keep
daniel.keep.lists at gmail.com
Mon Mar 19 22:43:28 PDT 2007
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.
-- Daniel
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d
mailing list