Discussion Thread: DIP 1029--Add throw as Function Attribute--Final Review

Panke tobias at pankrath.net
Tue May 5 18:02:34 UTC 2020


On Saturday, 18 April 2020 at 16:28:59 UTC, NaN wrote:
> You could have the caller pass an alternate return address to 
> the callee. So...
>
> void copy(string src, string dest, void* err)
> {
>     if (somethingbad) { EAX = errorcode; RET (to) err; } ***
> }
>
> void main()
> {
>     auto result = copy("foo", "bar", &L1);
>
>     return;
>
>     L1: writeln("Oh noes!");
> }
>
> *** So all the callee has to do is poke the alternate return 
> address into the stack and RET as normal. (On x86 at least).

A paper describing the idea.

https://dl.acm.org/doi/pdf/10.1145/1016848.1016864

I thought there was a more practical one, but only found this.


More information about the Digitalmars-d mailing list