Distance functions and topologies