Martingales and function spaces