A method of wiring a switch to control a light when the power cable from the panel or the rest of the circuit goes to the light before going to the switch.

In this case, standard 2 conductor cable is used, with the neutral conductor coded black, because both wires are hot. This is one of the few times you're allowed to use both conductors of a cable for hot wires. The other is when you wire a three-way switch.

To wire a switch loop, the neutral from the circuit gets wired to the neutral on the lamp socket, but the hot end gets wired to one conductor of the switch loop, and the other end of the switch loop gets wired to the hot of the circuit. Thus, the switch breaks the hot connection like it's supposed to. If the light is in the middle of the run, you would need to use a wire nut to connect the hot cables going in and out of the switch (and the one to the switch loop) together, as well as all the neutral connections. And of course, connect all the ground wires together.