Simple trampoline code

BCS none at
Thu Jun 11 20:44:23 PDT 2009

Hello Ellery,

> BCS wrote:
>> Hello Ellery,
>>> bearophile wrote:
>>>> I'm trying to convert to D2 the following (quite simplified up)
>>>> Python code, that implements a trampoline to run tail-call
>>>> functions with no stack overflow:
>> [...]
>>> How DO you define the signature of a function that returns itself?
>> Last I checked, you can't. Make it return a struct that has itself.
> Thanks for reading my code

I never bothered understanding what the OP's code does but to answered the 
question you asked: this is the closest I have seen to a function that can 
return (a pointer to) itself:

struct S { S function(int) fn; }

S foo(int i) { return S(&foo); }

More information about the Digitalmars-d-learn mailing list