Sometimes, when you have a flat and are not too far from home, you might be able to inflate the tire and cycle for a few kilometers, then reinflate it again etc. until you get back, and fix the tube in a more cosy environment.
Related to this, check also
this and
this post.
And if you have a gear hub and/or rollerbrake, check
this.