in reply to caller() mystery

Because counting frames is 0-indexed. You do not have a third frame, so caller(2) won't return anything.

Try calling f(0) and f(1).