Rendered at 12:06:46 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
mbeavitt 17 minutes ago [-]
Why would someone want to use a nested function, practically speaking?
anta40 2 minutes ago [-]
Say to strictly enforce modularity, e.g helper functions that can only be accessed within its function.
Pascal supports it (at least Turbo Pascal, no idea about ISO Pascal).
kloop 11 minutes ago [-]
So that you can name a section of code without polluting the namespace.
tpoacher 24 minutes ago [-]
What's a "trampoline"?
mananaysiempre 8 minutes ago [-]
Could be a number of things depending on context. In this case it’s a short function that adjusts some things and jumps to the actual functions (a “thunk” is another term for this). Specifically, if in GCC you write
int f(int x) {
int g(int y) { ... use x and y ... }
...
h(&g);
...
}
then what the compiled code for f does is construct on the stack a short piece of machine code:
mov <well-known register>, <frame pointer>
jmp <start of g’s code>
and &g points to the start not of g’s code but of this snippet on the stack, which has the parent function’s frame pointer compiled into it as a literal constant. The snippet is called a trampoline.
It's where you jump and then get immediately bounced back. Basically GOTOs with params
mananaysiempre 1 hours ago [-]
What about your older patch where -fno-trampolines meant a function pointer could either be a code pointer or a closure (descriptor) pointer, distinguished by a tag?
uecker 26 minutes ago [-]
My old patch from 2018? This was not accepted to GCC because it relied on function pointers being aligned and there were concerns with this.
But I prefer this approach anyhow, as it does not impose any run-time cost for checking the tag, and is easier to optimize.
Pascal supports it (at least Turbo Pascal, no idea about ISO Pascal).
But I prefer this approach anyhow, as it does not impose any run-time cost for checking the tag, and is easier to optimize.