3 ms·
The main problem with IIFE is the same as with a normal function: You cannot return the caller function from inside the closure, making the "short-circuit" mec
by Rucadi 2y ago
The main problem with IIFE is the same as with a normal function:
You cannot return the caller function from inside the closure, making the "short-circuit" mechanism provided by questionmark (?) operator not possible.
With the GCC Extension, we get around that using a construct that is pretty similar to IIFE, it allows to return a value from an immediate expression created by a block of code that is surrounded by ({})
The nice thing about this block ({}) is that the last statement is used as the "return value" without an explicit return, this disambiguates between the "expression" return and the "function" return.
Without compiler support, the short-circit is not possible, but with this feature + macros we can create a function that behaves like that.