In The Lord of the Rings, Tolkien portrays both the Hornburg and Minas Tirith as having at least one layer of wall that is not fully enclosed, and instead end by joining sheer cliffs. Similarly, the Black Gate into Mordor seems to be built into nearly impassable mountains.
This seems like it would work well enough in preventing an assault, but in a prolonged siege it seems like a numerically superior attacker would be able to overcome the defense’s mountain patrols and the natural difficulties or climbing, and could then set to work on having a harassing and reconnaissance position overlooking the defense’s walls. That said, it seems like a cheap way to get a defended enclosure, it could be hard to actually establish those positions against a defense that is already in place, and in the case of trying to close off easy access through a mountain pass (as in the Black Gate and the Deeping Wall of Helm’s Deep) it seems like a ‘close enough’ option that is potentially orders of magnitude more achievable than building a wall around the entire valley.
I’m curious whether this sort of defensive wall was constructed in reality, particularly because I find that I seem to be projecting this set up onto historical defensive structures without really knowing that’s what they looked like – for example the “Gates of Alexander,” various parts of the Roman Limes and Alpine defenses particularly (Claustra Alpium Iuliarum), and the walls of Petra. However the closest I can find in pictures of ruins or maintained castles tend to be closer to cliff dwellings than the sort of ‘cliff to cliff curtain’ that I’m imagining.
Source: reddit post