Carbon nanotubes are one dimensional and very narrow. These obvious facts imply that, under doping with boron and nitrogen, microscopic doping inhomogeneity is much more important than for bulk semiconductors. We consider the possibility of exploiting such fluctuations to create interesting devices. Using the self-consistent tight-binding technique, we study heavily doped highly compensated nanotubes, revealing the spontaneous formation of structures resembling chains of random quantum dots, or nanoscale diodelike elements in series. We also consider truly isolated impurities, revealing simple scaling properties of bound state sizes and energies.