2 ms·
Determining whether an abstraction is zero-cost or not is often buried deep in a language's implementation, so you'd need an expert to determine whether a given
by kibwen 10y ago
Determining whether an abstraction is zero-cost or not is often buried deep in a language's implementation, so you'd need an expert to determine whether a given abstraction in Swift or SML qualifies. But regarding closures specifically, I can say that it's very unlikely that either Swift or SML have a zero-cost implementation, since having stack-allocated closures is an immense and deliberate decision in language design (AFAIK only C++ and Rust do this).