Stackless resumable functions
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 21 19:35:28 PST 2015
On Sat, 21 Feb 2015 21:19:32 +0000, bitwise wrote:
> Input on this would be appreciated.
it seems to me that you can "abuse" delegates for this (i mean the
underlying "fat pointer"). resumable function can create closure (i think
all the code for this is already here), "resume address" pointer (this
can be added to closure), pointer to "real" delegate, hidden "yield
point" address, and return a delegate which does something like this on
call:
* executes "real" delegate from "resume address".
* "real" delegate yields by doing indirect call to "resume address"
* assembler code at "resume address" stores new resume address (it's on
stack now)
* and returns from "wrapping delegate"
so from the point of programmer this will look as an ordinary delegate,
even with the same type, and it will be usable anywhere where ordinary
delegate is usable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150222/69d7d548/attachment.sig>
More information about the Digitalmars-d
mailing list