The implementation is so simple it might be considered cheating: at almost every step the expr_ternary is just converted to expr_if.