Why do walls exist around cities or parts of countries? These attempts to keep invaders out – or inhabitants in – have a long history. The concept looms large in Donald Trump’s threats to build a barrier along the United States-Mexico border and in the fenced-off Israeli annexation of Palestinian territories. The cold war-era partitions between East and West Berlin are not such a distant memory.

Bring down that wall: China officially scraps border around Shenzhen’s old special economic zone

China, too, has a long history of walling itself off from the rest of the world. The process continues in cyberspace, with the “Great Firewall Of China” not being an entirely facetious label. While the Great Wall of China is the best-known physical example, most Chinese cities have had external walls. Modern Xian and Nanjing retain magnificent stone and brick ramparts marked by superb entrance towers.

Beijing’s Ming-era city walls were once one of the capital’s crowning architectural glories. Their destruction in the 1950s, to create a series of massive ring roads, was an example of the Communist Party’s deliberate obliteration of national heritage. Fortunately, a few notable structures, such as Qianmen, were spared, and now stand marooned amidst the thundering traffic, like ghosts from another age.

Illegal buildings demolished in revamp of old area in Beijing

Examples exist closer to Hong Kong. Among the least noticed of Macau’s historical sites are the city’s fragmentary walls, which – like those elsewhere in China – mostly date from the Ming period (1368-1644). From the 1630s until they were largely demolished in the 1860s, walls stood around what today is the city’s central area. For the first 70 years of Portuguese settle­ment after 1557, no substantial walls had existed around the newly established town; no one – Chinese or Portuguese – saw any need for them.

Walls were eventually built to deal with the expanding number of foreigners on the China coast. Macau’s city walls served two purposes: to keep newcomers out if they were troublesome; and, should their presence prove useful, as in the case of the Portuguese, to pen them in, like so much domestic livestock.

And who were to be kept out? Other foreign powers with territorial ambitions, such as the Dutch and British, who posed an increased threat as Portuguese tech­nological superiority and maritime power waned during the early 17th century. Repeated Dutch attacks on Macau in particular proved to the Chinese the dangers these newcomers posed.

Walls also afforded a peaceful and convenient control mechanism when foreigners needed to be shown who was ultimately in charge. As Austin Coates observed in his short history of the city, A Macao Narrative (1978), if the Chinese population was ordered out, and the city gates closed, “food supplies would be cut off. They would be starved into obedience. The sole item of nourishment that Macao produced was well water”.

Macau-based author on his love affair with art history

The traditional Chinese approach to “barbarian” management – whether concerning Tartars from Central Asia or “ocean barbarians” such as the Portuguese – was to let them look after themselves. Physical separation saved the Sons of Heaven from the nuisance of direct connection with foreigners. Tartar cities, legation quarters, foreign concessions, international settlements and, now, special administrative regions – all these fenced-off sections served the same basic purpose across China’s history.

The “use barbarians to manage barbarians” policy is related to the intellectual strategy behind the “one country, two systems” formula. These days, Hong Kong and Macau’s walls with China are more psychological than actual, and mostly legal and admin­istrative in everyday practical terms.

These “walls” become more porous, transparent and irrelevant with every passing year, and will one day disappear altogether as both cities converge fully with China.