REF: use named funcs instead of lambdas
Working on #19296, having named functions instead of lambdas makes troubleshooting easier.
@jorisvandenbossche any idea whats going on in the doc build? rebased+green thanks