That, however, is just the potential energy added to the weight! We could tie the weight by a string to a similar weight on the floor--denoted B --and pass the string over a pulley. Then--with an ideal pulley having no friction, and an ideal string having no weight--if the mass on the table is pushed over the edge, the slightest downward push will make it descend all the way to the floor, while B is raised to the level of the table.
Work W was performed in raising mass B, while mass A has given up its potential energy. That shows energy is indeed "ability to perform work": potential energy was given up, and in return work was performed.
The work performed in raising B was again invested in potential energy. With ideal pulleys, strings etc., that energy again equals W, illustrating the conservation of energy. In an ideal set-up with no losses, this energy could be used to raise A to its previous height. Note that our working definition "energy is anything that can turn a machine" also holds, since a dropping weight could indeed turn a machine.
Energy is always preserved but--as seen in an earlier section--not always in a usable form. Suppose the weight A is tied, not to an equal weight on the floor, but to a block of concrete on a table (Figure 2). If the force of sliding friction of the block on the tabletop is exactly equal to mg, then dropping A allows the block to slide a distance h and overcome F along it.
But now the potential energy mgh has been converted to heat, generated by friction. This is energy too--but energy dispersed on the molecular level, hard to convert back to work. And as noted in section 15 on energy, even with ideal devices and substances, physics can at most promise the recovery of a certain fraction of that energy, never all of it.