A moat is a deep, broad ditch, either dry or filled with water, that is dug and surrounds a castle, fortification, building or town, historically to provide it with a preliminary line of defence. In some places moats evolved into more extensive water defences, including natural or artificial lakes, dams and sluices. In older fortifications, such as hillforts, they are usually referred to simply as ditches, although the function is similar. In later periods, moats or water defences may be largely ornamental.