ts2c icon indicating copy to clipboard operation
ts2c copied to clipboard

IIFE conversion?

Open CrazyPython opened this issue 6 years ago • 1 comments

let name = () => {
    declarations;
    return rvalue;
}()

to

type name;
{
    declarations;
    name = rvalue;
}

CrazyPython avatar Mar 25 '19 11:03 CrazyPython

Thanks for the idea!

One thing though: if there are multiple returns inside IIFE, that makes things a bit ugly, because we would have to break from the block using goto in that case.

In overall, I think the idea is sound, but I would propose to only optimize simple IIFEs with that approach - ones that don't return values and don't have any return statements inside.

andrei-markeev avatar Mar 26 '19 02:03 andrei-markeev