Architecture of the Song dynasty and Raku (programming language): Difference between pages

(Difference between pages)
Content deleted Content added
mNo edit summary
 
Notifying of internal link to section Syntactic simplification from Ellipsis
 
Line 1:
{{beta software}}
[[Image:Liuhe Pagoda.jpg|thumb|right|250px|The [[Liuhe Pagoda]], or Six Harmonies Pagoda, erected in 1156 AD and fully reconstructed in 1165 AD.]]
 
'''Perl 6''' is a planned major revision to the [[Perl]] [[programming language]]. Perl 6 introduces elements of many modern and historical languages. Perl 6 is not intended to be [[Backward compatibility|backwards-compatible]] with earlier versions of Perl, though a [[compatibility mode]] is part of the specification.
Like every subsequent dynastic period of [[China]], the '''[[architecture]] of the [[Song Dynasty]]''' was based upon the accomplishments of its predecessors. In terms of architecture, the profession of the [[architect]], [[craftsman]], [[carpenter]], and building [[engineer]] weren't seen as high professions equal to the likes a [[Confucian]] scholar-official. Architectural knowledge was passed down orally for thousands of years in China, from a father craftsman to his son (if the son wished to continue the legacy of his father).
 
Perl 6 has been under development for over seven years, prompting some commentators to suggest that Perl 6 may be [[vaporware]]. The Perl 6 project has never had a clear timeline, although various contributors have given estimates over the years. In early 2007 [[Jesse Vincent]], the Perl 6 Project Manager said, "The Perl 6 project has no schedule ... one doesn't want to rush a largely volunteer effort to design and implement a worthy successor to Perl 5."<ref>{{cite web | title=List discussion about future Perl 5 development | author=Perl 6 Project Manager | url=http://www.nntp.perl.org/group/perl.perl5.porters/120613 | year=2007}}</ref>
During the [[Song Dynasty]] ([[960]]–[[1279]] AD), previous works on architecture were brought to more sophisticated levels of description, such as the ''Yi Li Shi Gong'', written by [[Li Ruo-gui]] in 1193 AD.<ref name="needham volume 4 81">Needham, Volume 4, 81.</ref> One of the most difinitive works, however, was the earlier ''Mu Jing'' ('Timberwork Manual'), ascribed to the Master-Carpenter (Du Liao Jiang) known as [[Yu Hao]], written sometime between 965 to 995. Yu Hao was responsible for the construction of an elegant wooden pagoda tower in Kaifeng, one that unfortunately was burnt down by lightning and replaced by a brick pagoda soon after (refer to Iron Pagoda of Youguo Temple below). In his time, books on architecture were still considered a lowly scholarly achievement since it was associated with a middle-class craft, therefore it was not even recorded in the official court bibliography.<ref name="needham volume 4 82">Needham, Volume 4, 82.</ref> However, the scientist and statesman Shen Kuo wrote of his work extensively around 1080, praising the Timberwork Manual as a work of architectural genius, and that no one in his own time could reproduce such a work (refer to article on [[Shen Kuo]]).<ref name="needham volume 4 84">Needham, Volume 4, 84.</ref> However, several years later, there was such a man, known as [[Li Jie]], who wrote the ''Ying Zao Fa Shi'' ('Treatise on Architectural Methods').<ref name="needham volume 4 84"/>
 
There is currently a slow, but mostly complete, implementation written in the [[Haskell (programming language)|Haskell]] programming language called [[Pugs]], and two alternative implementations exist, one based on [[Parrot (virtual machine)|Parrot]] and [[Parser Grammar Engine|PGE]] and the other on [[Perl|Perl 5]].
When Shen Kuo was in office, Li Jie was an up-and-coming official in the Bureau of Imperial Sacrifices, and by 1092 he had been moved to the Directorate of Buildings and Construction, where he showed much promise as an architect.<ref name="needham volume 4 84"/> He revised many older treatises on architecture in 1097, his work complete in [[1100]], and officially published three years later.<ref name="needham volume 4 84"/> He became well-known for the oversight in construction of administrative offices, palace apartments, gates and gate-towers, the [[ancestor worship|ancestral temple]] of the Song Dynasty, along with numerous [[Buddhist temple]]s.<ref name="needham volume 4 84"/> His written work included building rules and regulations, accounting information, materials used in construction, classification of different crafts, and outlined the construction of:
 
==History==
*Moats and fortifications
*Stonework
*Greater woodwork
*Lesser woodwork
*Wood-carving
*Turning and drilling
*Sawing
*Bamboo work
*Tiling
*Wall building
*Painting and decoration
*Brickwork
*Glazed tile making<ref name="needham volume 4 85">Needham, Volume 4, 85</ref>
 
The Perl 6 design process was first announced on July 19, [[2000]], on day 4 of that year's [[OSCON|Perl Conference]],<ref>{{cite web | title=Report from the Perl Conference | url=http://www.perl.com/pub/a/2000/08/tpc4.html | author=Kline, Joe | date=[[2000-08-21]] }}</ref> by [[Larry Wall]] in his ''State of the Onion 2000'' talk.<ref>{{cite web | title=State of the Onion 2000 | author=[[Larry Wall|Wall, Larry]] | publisher=O'Reilly Network | url=http://www.perl.com/pub/a/2000/10/23/soto2000.html | year=2000}}</ref> At that time, the primary goals were to remove "historical warts" from the language; "easy things should stay easy, hard things should get easier, and impossible things should get hard;" a general cleanup of the internal design and APIs. The process began with a series of [[Request for Comments|requests for comments]] or "RFCs". This process was open to all contributors, and left no aspect of the language closed to change.<ref>{{cite web | title=About Perl6 RFCs | author=The Perl Foundation | url=http://dev.perl.org/perl6/rfc/meta/ | year=2000}}</ref>
 
Once the RFC process was complete, Wall reviewed and classified each request. He then began the process of writing the Apocalypses, the name of which refers to "a revealing" according to the first such document.<ref name="apoc1">{{cite web | url=http://dev.perl.org/perl6/doc/design/apo/A01.html | title=Apocalypse 1: The Ugly, the Bad, and the Good | author=Wall, Larry | date=[[2001-04-02]]}}</ref> While the original goal was to write one Apocalypse for each chapter of ''Programming Perl'', it became obvious that, as each Apocalypse was written, previous Apocalypses were being invalidated by later changes. For this reason, a set of Synopses were published, each one relating the contents of an Apocalypse, but with any subsequent changes reflected in updates. Today, Perl 6 specification continues almost entirely within the Synopses.<ref name="syn">{{cite web | author=The Perl Foundation | title=Perl Development: Synopses | url=http://dev.perl.org/perl6/doc/synopsis.html | year=2002}}</ref>
==Buddhist pagoda towers==
[[Image:Pagoda Yunyan Ta.jpg|left|200px|thumb|The [[Huqiu Tower]], also known as the Yunyan Pagoda, built in 961 AD.]]
 
There are also a series of Exegeses written by [[Damian Conway]] that explain the content of each Apocalypse in terms of practical usage. Each Exegesis consists of code examples along with discussion of the usage and implications of the examples.<ref name="exegeses">{{cite web | url=http://dev.perl.org/perl6/doc/exegesis.html | title=Exegeses | author=The Perl Foundation | year=2001}}</ref>
During the [[Han Dynasty]] of [[China]] ([[202 BC]]&ndash;[[220]] AD), the idea of the [[Buddhist]] [[stupa]] entered [[Chinese culture]], as a means to house and protect scriptural [[sutra]]s. During the [[Southern and Northern Dynasties]] period, the distinct Chinese [[pagoda]] was developed, its predecessor being the tall watchtowers and towering residential apartments of the Han Dynasty (as seen through Han-era tomb models).<ref>Hoover, M. (August 2006).[http://www.accd.edu/sac/vat/arthistory/arts1303/China1.htm The Art of Early China and Korea] M. Hoover and San Antonio College. Retrieved on [[2007-03-29]].</ref><ref name="needham volume 4 128">Needham, Volume 4, 128.</ref> During the Sui ([[581]]&ndash;[[618]]) and Tang ([[618]]&ndash;[[907]]) periods, [[Chinese pagoda]]s were reverted from purely wooden architecture into [[stone]] and [[brick]], which could more easily survive lightning fires, arson, and avoid the natural rotting of wooden material over the ages. A good example of Tang era pagodas would be the [[Giant Wild Goose Pagoda]], constructed by [[652]]. Although Buddhism in China had waned in influence after the late Tang period, during the Song Dynasty there were numerous Buddhist pagoda towers built. Tall Chinese pagodas were often built in the surrounding countryside instead of within the city walls, due to its foreign origin in India, and the Chinese not wanting it to compete with the cosmic-imperial authority embodied in the cities' drum-towers and gate-towers.<ref name="needham volume 4 137">Needham, Volume 4, 137.</ref>
 
There are three primary methods of communication used in the development of Perl 6 today. The first is the [irc://irc.freenode.net/#perl6 #perl6] [[Internet Relay Chat|IRC channel]] on [[freenode]]. The second is a set of [[mailing list]]s on [[The Perl Foundation]]'s servers at [http://perl.org perl.org].<ref name="lists">{{cite web | title=Perl Development: Mailing Lists | author=The Perl Foundation | url=http://dev.perl.org/perl6/lists/ | year=2002}}</ref> The third is the [[Subversion (software)|Subversion]] [[source code repository]] used by the [[pugs]] team. Pugs is an early implementation of Perl 6; see the [[#Implementations|Implementations]] section for more detail.
The '[[Iron Pagoda]]' of [[Youguo Temple]] in [[Kaifeng]] is an excellent example of Song-era architecture, earning its name because of the iron-grey color of the glazed-bricks forming the tower. Originally built as a wooden pagoda by the architect [[Yu Hao]], it was struck by lightning and burned down in 1044 during the Northern Song period. In 1049 the pagoda was rebuilt as it appears today, under the order of [[Emperor Renzong of Song]]. This [[octagon]]al-base pagoda structure stands at a current height of 56.88 meters (186.56 feet tall), and with a total of 13 story levels.<ref>Chinadaily.com.cn (2003).[http://www.chinaculture.org/gb/en_travel/2003-09/24/content_36209.htm Iron Pagoda]. Ministry of Culture. Retrieved on [[2007-03-29]].</ref> It's glazed tile bricks feature carved artwork of dancing figures, solemn ministers, and Buddhist themes (see Gallery below).
 
[[As of 2007]], Perl 6 was still under development, with no planned completion date.
However, China also featured real iron-cast pagodas, such as the Iron Pagoda of [[Yuquan Temple]] (Jade Springs Temple), [[Dangyang]], [[Hubei]] Province. Built in 1061 AD during the Northern Song, it holds a weight of 53848&nbsp;kg (53&nbsp;t) of [[cast iron]], at a standing height of 21.28&nbsp;m (70&nbsp;ft tall).<ref name="needham volume 4 141 142">Needham, Volume 4, 141-142.</ref> In mock and model after the roofing tiles of actual wooden, stone, or brick pagodas of the Song period, this iron pagoda features delicate sloping eaves, with an octoganal base.<ref>China.org.cn [http://www.china.org.cn/english/TR-e/43293.htm Iron Pagoda at Yuquan Temple in Dangyang of Hubei Province]. China Internet Information Center. Retrieved on [[2007-03-29]].</ref>
 
===Goals===
[[Image:Wooden Pagoda Shanxi.jpg|thumb|200px|right|The [[Khitan]] wooden Yingxian [[Pagoda]] of [[Shanxi]] province, built in 1056 AD.]]
The break in compatibility was mandated from the start of the project, and immediately allowed some of the changes that Larry Wall had suggested in his initial speech. "Historical warts" such as the confusion surrounding sigil usage for containers; the ambiguity between the select functions; the syntactic impact of bareword filehandles; and many other problems that Perl programmers had discussed fixing for years were some of the first issues addressed.
The [[Liuhe Pagoda]], or Six Harmonies Pagoda, is another famous Song-era work of pagoda architecture. It is located in the Southern Song capital of Hangzhou, [[Zhejiang]] Province, China, at the foot of the Yuelun Hill facing the [[Qiantang River]]. Although the original was destroyed in 1121, the current tower was erected in 1156, fully restored by 1165. It stands at a height of 59.89&nbsp;m (196&nbsp;ft tall), constructed from a red-brick frame with 13 layers of wooden eaves. The Liuhe Pagoda, being of considerable size and stature, served as a permanent [[lighthouse]] from nearly its beginning, to aid [[sailor]]s in seeking [[anchor]]age for their ships at night (as described in the ''Hangzhou Fu Zhi'').<ref name="needham volume 4 662">Needham, Volume 4, 662.</ref> During the Southern Song period, it was one of the crowning pieces of architecture for the capital city.
 
Over the years, Perl 6 has undergone several alterations in its direction. The introduction of concepts from [[Python (programming language)|Python]] and [[Ruby programming language|Ruby]] were early influences, but as the pugs interpreter was written in the [[Haskell (programming language)|Haskell programming language]], many [[functional programming]] influences were absorbed by the Perl 6 design team.
The [[Liao Dynasty]] to the north was also famous for its Buddhist pagoda architecture. Although many brick and stone pagodas, and brick-stone/wood hybrid pagodas built beforehand have survived the ages, the tallest and oldest fully-wooden pagoda still standing in China was of Liao-Khitan making, the Yingxian Pagoda.<ref>Dias del futuro pasado ([[September 4]] [[2006]]). [http://www.futuropasado.com/?p=489 The Wooden Pagoda of Yingxian]. futuropasado.com. Retrieved on [[2007-03-29]]. {{es_icon}}</ref><ref name="steinhardt 103">Steinhardt, 130.</ref> Located in [[Yingxian County]] of [[Shanxi]] Province, the octogonal-base pagoda was built in 1056 AD, as a crowning architectural masterpiece of the [[Fogong Temple]]. The pagoda stands at a height of 67.13&nbsp;m (220.18&nbsp;ft) tall, making it taller than both the Iron Pagoda and the Liuhe Pagoda of the Song Dynasty.<ref>Chinadaily.com.cn (2003).[http://www.chinaculture.org/gb/en_travel/2003-09/24/content_34464.htm Sakyamuni Pagoda at Fogong Temple]. Ministry of Culture. Retrieved on [[2007-03-29]].</ref> The pagoda also features just under sixty different kinds of [[bracket]] arms in its construction.<ref name="needham volume 4 131">Needham, Volume 4, 131.</ref> The pagoda was built in a similar style to the Liuhe Pagoda, with its delicate wooden eaves and curving tiles, and along with the other pagodas it is a site of tourist attraction in modern times. Apparently, the pagoda was built by Emperor Daozong of Liao (Hongji) at the site of his grandmother's family home.<ref name="steinhardt 20">Steinhardt, 20.</ref> The pagoda reached such fame that it was commonly nicknamed simply the "Mu-ta" (Timber Pagoda) in China.<ref name="steinhardt 103"/>
 
==Implementations==
===Iron Pagoda gallery===
Pugs is an implementation of Perl 6 written in [[Haskell (programming language)|Haskell]]. It is currently the closest thing to a full implementation of Perl 6. It will be used for [[Bootstrapping (compilers)|bootstrapping]], providing a platform on which to write the Perl 6 compiler in Perl 6, and the test suite to validate it. This could, for example, involve translating the Pugs Haskell [[source code]] to Perl 6.<ref>{{cite web | url=http://www.pugscode.org/ | title=pugscode: Pugs | author=[[Audrey Tang|Tang, Audrey]] | year=2005 }}</ref> After that, Perl 6 will be [[self-hosting|self-hosted]]&mdash;it will be used to [[compiler|compile]] itself. Much of the implementation of Perl will then be exposed to programmers using the language. For example, this would make it possible to extend the parser from within a program or library. Pugs can execute Perl 6 code directly, and has also compiled Perl 6 to [[JavaScript]], [[Perl|Perl 5]] and Parrot [[bytecode]]. Lacking funding, even the key developer [[Audrey Tang]] is only working part time, so progress has not been as rapid as many wish.
<gallery>
Image:Iron Pagoda of Kaifeng.jpg
Image:Iron Pagoda of Kaifeng 2.jpg
Image:Iron Pagoda of Kaifeng 3.jpg
Image:Iron Pagoda of Kaifeng 4.jpg
Image:Iron Pagoda of Kaifeng 5.jpg
Image:Iron Pagoda of Kaifeng 6.jpg
Image:Iron Pagoda of Kaifeng 7.jpg
</gallery>
 
[[Parrot virtual machine|Parrot]] is a [[virtual machine]] designed for interpreted languages, primarily for Perl 6. The self-hosting Perl 6 compiler will (according to plan) target and also run on Parrot.<ref name="syn01">{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S01.html | title=Synopsis 1: Overview | author=Wall, Larry | date=[[2004-08-10]] }}</ref><ref name="selfhost">{{cite web | url=http://www.pugscode.org/talks/yapc/slide71h.html | title=Perl 6 Is Here Today: Self hosting approach | author=[[Autrijus Tang|Tang, Autrijus]] | year=2005 | publisher=pugscode.org}}</ref>
==Grandiose bridges==
 
<code>[[v6 (Perl)|v6.pm]]</code> is a pure Perl 5 implementation of Perl 6, making liberal use of existing [[CPAN]] modules, such as <code>Moose</code> and <code>Pugs::Compiler::Rule</code>. It aims to make the existing perl runtime a first-class virtual machine for both Perl 5 and Perl 6.<ref name="v6Release">{{cite web | url=http://use.perl.org/article.pl?sid=06/07/07/1532235&from=rss | title=Pugs 6.2.12 and v6.pm released! | author=audreyt | publisher=use Perl }}</ref>
[[Image:Zhaozhou Bridge.jpg|thumb|left|265px|The [[Zhaozhou Bridge]] of [[605]] AD, a segmental arch bridge that would inspire later bridge-works in China.]]
[[Bridge]]s over waterways had been known in China since the ancient [[Zhou Dynasty]], and even floating [[pontoon]] bridges were mentioned from the Zhou period (Song era pontoon bridges include the [[Dongjin Bridge]], 400 meters long, which is still seen today). Bridges of the Zhou Dynasty were often built entirely of wood, while some featured stone piers. The first bridge in China to be built entirely of stone was an arch bridge of 135 AD, spanning a transport canal in the Eastern Han capital of [[Luoyang]].<ref name="needham volume 4 152 153">Needham, Volume 4, 152-153.</ref> With brilliant engineers such as Li Chun of the Sui period, grand bridge-works like the [[Zhaozhou Bridge]] of 605 AD were built. In terms of global history, this bridge is famous for being the world's first [[spandrel|open-spandrel]] stone segemental [[arch bridge]]. Although the bridge of [[Roman Empire|Roman]] Emperor [[Trajan]] over the [[Danube]] featured wooden-built open-spandrel segmental arches on stone piers ([[Trajan's Bridge]]), the first purely-stone segmental arch bridge built in Europe was the [[Ponte Vecchio]] Bridge of [[Florence]], built in 1335.
 
In [[2007]], v6-MiniPerl6 ("mp6") and its reimplementation, v6-KindaPerl6 ("kp6") were written as a means to bootstrap the Perl-6.0.0 STD, using Perl 5. The STD is a full grammar for Perl 6, and is written in Perl 6. In theory, anything capable of parsing the STD and generating executable code is a suitable bootstrapping system for Perl 6. kp6 is currently compiled by mp6 and can work with multiple backends.<ref>{{cite web | url=http://darcs.pugscode.org/v6/v6-KindaPerl6/docs/FAQ.pod | title=mp6/kp6 FAQ | year=2006 | publisher=Perl 6 development team}}</ref><ref>{{cite web | url=http://dev.pugscode.org/browser/src/perl6/Perl-6.0.0-STD.pm | title=Perl 6 STD | author=Wall, Larry, et al. | year=2007}}</ref> mp6 and kp6 are not full Perl 6 implementations, and are designed only to implement the minimum featureset required to bootstrap a full Perl 6 compiler.
During the Song Dynasty, bridge construction reached an even greater height of sophistication and grand extent. There were large [[trestle]]-structure bridges built during the Song, like the one built by [[Zhang Zhong-yan]] in 1158 AD.<ref name="needham volume 4 150">Needham, Volume 4, 150.</ref> There were also large bridges built entirely of stone, such as the [[Ba Zi Bridge]] of [[Shao-Xing]], built in 1256 AD, which still stands today.<ref name="needham volume 4 153">Needham, Volume 4, 153.</ref> Bridges with stylish Chinese [[pavilion (structure)|pavilion]]s crowning their central spans were often featured in painted artwork, like the landscape paintings of [[Xia Gui]] ([[1195]]–[[1224]]). In 1221, the Daoist traveler [[Qiu Chang-chun]] once visited [[Genghis Khan]] in [[Samarkand]], describing various Chinese bridges in his travels there through the [[Tian Shan]] Mountains, east of [[Yining|Kuldja]]. Joseph Needham quotes him as saying:
[[Image:Lu gou qiao.jpg|thumb|right|200px|The [[Lugou Bridge]] ([[Marco Polo]] Bridge), constructed from 1189 to 1192, although the current bridge was reconstructed in 1698.]]
<blockquote>
[The road had] 'no less than 48 timber bridges of such width that two carts can drive over them side by side'. It had been built by Chang Jung [Zhang Rong] and the other engineers of the [[Chagatai]] some years before. The wooden trestles of Chinese bridges from the -3rd century (BC) onwards were no doubt similar to those supposed to have been employed in [[Caesar]]'s bridge of -55 (BC) across the [[Rhine]], or drawn by [[Leonardo da Vinci|Leonardo]], or found in use in Africa. But where in +13th century (AD) Europe could a two-lane highway like Chang Jung's have been found?<ref name="needham volume 4 151">Needham, Volume 4, 151.</ref>
</blockquote>
 
== Major changes from Perl 5 ==
In medieval-era [[Fujian]] Province, there were enormous beam bridges built during the Song Dynasty. Some of these bridges were built at a length of 1219.2&nbsp;m (4,000&nbsp;ft), with the length of their individual spans of up to 22.33&nbsp;m (70&nbsp;ft) in length, and the construction of which necessitated the moving of massive stones that weighed 203200&nbsp;kg (200&nbsp;t).<ref name="needham volume 4 153"/> Unfortunately, no names of the engineers of the Fujian bridges were recorded or featured on inscriptions of the bridges. The only names featured were merely the names of the Song-era local officials that sponsored them and gave oversight of their construction and repair.<ref name="needham volume 4 153"/> However, the historian Joseph Needham points out that there might have been an engineering school of Fujian headed by a prominent engineer of the time known as [[Cai Xiang]] ([[1012]]&ndash;[[1067]]). Cai was a noted scholar, an author of books on lichi fruit and tea, and who had risen to the seat of a governmental [[prefect]] in Fujian. At [[Quanzhou]], Cai Xiang planned, supervised, and had erected the [[Wan-an Bridge]], similar to other bridges found in Fujian.<ref name="needham volume 4 153"/>
Perl 5 and Perl 6 differ fundamentally, though in general the intent has been to "keep Perl 6 Perl". Most of the changes are intended to normalize the language, to make it easier for learning and expert programmers alike to understand, and to make "easy things easier and hard things more possible".
 
=== A specification ===
==Shen Kuo's dissertation on the Timberwork Manual==
 
A major, but non-technical difference between Perl 5 and Perl 6 is that Perl 6 began as a specification.<ref name="syn01"/> This means that Perl 6 can be re-implemented if needed, and it also means that programmers don't have to read the source code for the ultimate authority on any given feature. Perl 5's documentation was regarded as excellent, even outside of the Perl community where even mixed reviews typically noted its maturity and breadth. However, if the documentation and the source code of the Perl 5 interpreter disagreed, the documentation was not considered authoritative, and would be changed.
(As stated in the introduction) [[Shen Kuo]] was one to praise the architectural written work of Yu Hao, who once had a marvelous wooden Chinese pagoda built at the Song capital of [[Kaifeng]]. Below is a passage from one of Shen's books outlining the basics contained in Yu's 10th century work on early Song-era architecture:
 
=== A type system ===
In the first quote, Shen Kuo describes a scene were Yu Hao gives advice to another artisan architect about slanting [[strut]]s for diagonal wind bracing (Wade-Giles spelling):
 
In Perl 6, the [[Datatype#Static and dynamic typing|dynamic type system]] of Perl 5 has been augmented by the addition of static types.<ref name="syn2">{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S02.html | title=Synopsis 2: Bits and Pieces | author=Wall, Larry | date=[[2004-08-10]] }}</ref> For example:
{{cquote|When Mr. Chhien (Wei-Yen) was Governor of the two [[Chekiang]] provinces, he authorized the building of a wooden pagoda at the Fan-Thien Ssu ([[Brahma]]-Heaven Temple) in [[Hangchow]] with a design of twice three stories. While it was under construction General Chhien went up to the top and was worried because it swayed a little. But the Master-Builder explained that as the tiles had not yet been put on, the upper part was still rather light, hence the effect. So then they put on all the tiles, but the sway continued as before. Being at a loss what to do, he privately sent his wife to see the wife of Yu Hao with a present of [[gold]]en [[hair pin]]s, and enquire about the cause of the motion. (Yu) Hao laughed and said: 'That's easy, just fit in struts (pan) to settle the work, fixed with ([[iron]]) [[nail]]s, and it will not move any more.' The Master-Builder followed his advice, and the tower stood quite firm. This is because the nailed struts filled in and bound together (all the members) up and down so that the six planes (above and below, front and back, left and right) were mutually linked like the cage of the [[thorax]]. Although people might walk on the struts, the six planes grasped and supported each other, so naturally there could be no more motion. Everybody acknowledged the expertise thus shown.<ref name="needham volume 4 141">Needham, Volume 4, 141.</ref>}}
my Int $i = 0;
my Num $n = 3.142;
my Str $s = "Hello, world";
However, as with Perl 5, programmers can do most things without any explicit typing at all:
my $i = "25" + 10; # $i is 35
 
Proponents of [[Type system|static typing]] claim that it is beneficial to compiler optimization, reducing programming errors and increasing maintainability, especially in large software projects.
In this next quote, Shen Kuo describes the dimensions and types of architecture outlined in Yu Hao's book (Wade-Giles spelling):
 
On the other hand, [[Type system|dynamic typing]] reduces input source code size,{{Fact|date=June 2007}} which is the bottleneck on smaller projects. It is helpful when writing quick [[scripting programming language|script]]s, [[one-liner program|one-liners]] or "one-off" code (i.e., code that is written to achieve some temporary purpose and will be run once).
{{cquote|Methods of building construction are described in the ''Timberwork Manual'', which, some say, was written by Yu Hao. (According to that book), buildings have three basic units of proportion (fen), what is above the cross-beams follows the Upperwork Unit, what is above the ground floor follows the Middlework Unit, and everything below that (platforms, foundations, paving, etc.) follows the Lowerwork Unit. The length of the cross-beams will naturally govern the lengths of the uppermost cross-beams as well as the rafters, etc. Thus for a (main) cross-beam of (8&nbsp;ft.) length, an uppermost cross-beam of (3.5&nbsp;ft.) length will be needed. (The proportions are maintained) in larger and smaller halls. This (2/28) is the Upperwork Unit. Similarly, the dimensions of the foundations must match the dimensions of the columns to be used, as also those of the (side-) [[rafter]]s, etc. For example, a column (11&nbsp;ft.) high will need a platform (4.5&nbsp;ft.) high. So also for all the other components, [[corbel]]led brackets (kung), projecting rafters (tshui), other rafters (chueh), all have their fixed proportions. All these follow the Middlework Unit (2/24). Now below of ramps (and steps) there are three kinds, steep, easy-going, and intermediate. In places these gradients are based upon a unit derived from the imperial litters. Steep ramps (chun tao) are ramps for ascending which the leading and trailing bearers have to extend their arms fully down and up respectively (ratio 3/35). Easy-going ramps (man tao) are those for which the leaders use elbow length and the trailers shoulder height (ratio 1/38); intermediate ones (phing tao) are negotiated by the leaders with downstretched arms and trailers at shoulder height (ratio 2/18). These are the Lowerwork Units. The book (of Yu Hao) had three chapters. But builders (thu mu chih kung) in recent years have become much more precise and skillful (yen shan) than formerly. Thus for some time past the old Timberwork Manual has fallen out of use. But (unfortunately) there is hardly anybody capable of writing a new one. To do that would be a masterpiece in itself!<ref name="Needham volume 4 82 84">Needham, Volume 4, 82-84</ref>}}
 
Perl 6 offers a hybrid typing system whereby the programmer may choose to use Static Typing, Dynamic Typing or mix the two.
==See also==
*[[Chinese architecture]]
*[[Culture of the Song Dynasty]]
*[[Economy of the Song Dynasty]]
*[[History of the Song Dynasty]]
*[[List of Chinese inventions]]
*[[Society of the Song Dynasty]]
*[[Technology of the Song Dynasty]]
 
=== Formal subroutine parameter lists ===
==Notes==
 
Perl 5 defined subroutines without [[parameter (computer science)|formal parameter]] lists at all (though simple parameter counting and some very loose type checking can be done using Perl 5's "prototypes"). Subroutine arguments passed in were aliased into the elements of the array <tt>@_</tt>. If <tt>@_</tt> were modified, the changes would be reflected in the original data.
<div class="references-small">
 
<references/>
Perl 6 introduces true formal parameters to the language.<ref name="syn6">{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S06.html | title=Synopsis 6: Subroutines | author=Wall, Larry | date=[[2003-03-21]] }}</ref> In Perl 6, a subroutine declaration looks like this:
</div>
 
sub do_something(Str $thing, Int $other) { ... }
 
As in Perl 5, the formal parameters (i.e., the variables in the parameter list) are aliases to the actual parameters (the values passed in), but by default, the aliases are [[Variable#Constant|constant]] so they cannot be modified. They may be declared explicitly as read-write aliases for the original value or as copies using the <code>is rw</code> or <code>is copy</code> directives should the programmer require them to be modified locally.
 
====Parameter passing modes====
Perl 6 provides three basic modes of parameter passing:
* Positional
* Named
* Slurpy
Positional parameters are the typical ordered list of parameters that most programming languages use. All parameters may also be passed by using their name in an unordered way. A named-only parameter can only be passed by specifying its name (that is, it never captures a positional argument), and are indicated with a leading <code>:</code> character. Slurpy parameters (indicated by an <code>*</code> before the parameter name) are Perl 6's tool for creating [[variadic function]]s. A slurpy hash will capture remaining passed-by-name parameters, whereas a slurpy array will capture remaining passed-by-position parameters.
 
Here is an example of the use of all three parameter-passing modes:
 
sub somefunction($a, $b, :$c, :$d, *@e) {...}
somefunction(1, 2, :d<3>, 4, 5, 6); # $a=1, $b=2, $d=3, @e=(4,5,6)
somefunction(:b<2>, :a<1>); # $a=1, $b=2
 
Positional parameters, such as those used above are always required, unless followed by <code>?</code> to indicate that they are optional. Named parameters are optional by default, but may be marked as required by adding <code>!</code> after the variable name. Slurpy parameters are ''always'' optional.
 
====Blocks and closures====
Parameters can also be passed to arbitrary blocks, which act as [[Closure (computer science)|closures]]. This is how, for example, <code>for</code> and <code>while</code> loop iterators are named. In the following example, a list is traversed, 3 elements at a time, and passed to the loop's block as the variables, <code>$a, $b, $c</code>.
 
for @list -> ($a, $b, $c) { ... }
 
This is generally referred to as a "pointy sub" or "pointy block", and the arrow behaves almost exactly like the <code>sub</code> keyword, introducing an anonymous closure (or anonymous subroutine in Perl 5 terminology).<ref name="syn6"/>
 
=== Sigil invariance ===
In Perl 5, [[Sigil (computer programming)|''sigils'']] &mdash; the punctuation characters that precede a variable name &mdash; changed depending on how the variable was used:
# Perl 5 code
my <span style="color:red">@</span>array = (1, 2, 3);
my $element = <span style="color:red">$</span>array[1]; # $element equals 2
 
In Perl 6, sigils are invariant, which mean they do not change based on whether it is the array or the array element that is needed:<ref name="syn2"/>
# Perl 6 code
my <span style="color:red">@</span>array = (1, 2, 3);
my $element = <span style="color:red">@</span>array[1]; # $element equals 2
 
The variance in Perl 5 was inspired by natural language:
 
"'''The''' apple". # CORRECT
"'''These''' apples. # CORRECT
"'''The''' third one of the apples". # CORRECT
"'''These''' third one of the apples". # WRONG
 
The change in Perl 6 is meant to reduce the [[cognitive load]] of recognizing when to use the ''@'' or the ''$''.
 
=== Object-oriented programming ===
Perl 5 supported [[object-oriented programming]] via a mechanism known as ''blessing''. Any [[reference (computer science)|reference]] could be blessed into being an object of a particular class, a blessed object could have [[method (computer science)|method]]s invoked on it using the "arrow syntax" which would cause Perl to locate or "dispatch" an appropriate [[subroutine]] by name, and call it with the blessed variable as its first argument.
 
While extremely powerful&mdash;virtually any other computer language's [[object model]] could be simulated using this simple facility&mdash;it made the most common case of object orientation, a [[struct]]-like object with some associated code, unnecessarily difficult. In addition, because Perl could make no assumptions about the object model in use, method invocation could not be optimized very well.
 
In the spirit of making the "easy things easy but hard things possible", Perl 6 retains the blessing model but supplies a more robust object model for the common cases.<ref>{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S12.html | title=Synopsis 12: Objects | author=Wall, Larry | date=[[2006-08-18]] }}</ref> For example, a class to encapsulate a [[Cartesian coordinate system|Cartesian]] [[point (geometry)|point]] could be defined and used this way:
 
class Point is rw {
has $.x;
has $.y;
}
my Point $point .= new( :x<1.2>, :y<-3.7> );
# Now change x (note method "x" used as lvalue):
$point.x = 2;
say "Point is at X ___location: ", $point.x;
 
The dot replaces the arrow in a nod to the many other languages (e.g. [[Java (programming language)|Java]], [[Python (programming language)|Python]], etc.) that have coalesced around dot as the syntax for method invocation.
 
In the terminology of Perl 6, <code>$.x</code> is called an "attribute". Some languages call these fields or members. The method used to access an attribute is called an "accessor". Auto-accessors are methods that are created automatically, as the method <code>x</code> is in the example above. These accessor functions return the value of the attribute. When a class or individual attribute is declared with the <code>is rw</code> modifier (short for "read/write"), the auto-accessor can be passed a new value to set the attribute to, or it can be directly assigned to as an [[lvalue]] (as in the example). Auto-accessors can be replaced by user-defined methods, should the programmer desire a richer interface to an attribute. Attributes can only be accessed directly from within a class definition. All other access must go through the accessor methods.
 
==== Roles ====
Roles in Perl 6 take on the function of both ''interfaces'' in Java and [[Trait (abstract type)|traits]]<ref>{{cite web | title=Traits | url=http://www.iam.unibe.ch/~scg/Research/Traits/ | author=The Software Composition Group | year=2003}}</ref> in [[Smalltalk]] variant [[Squeak]]. These are much like classes, but are entirely [[Abstraction (computer science)|abstract]]. These are used to perform composition when used with classes rather than adding to their [[Inheritance (computer science)|inheritance]] chain. Roles define nominal types; they provide semantic names for collections of behavior and state.
 
The fundamental difference between a role and a class is that classes are instantiable; roles are not.<ref>{{cite web | title=Roles: Composable Units of Object Behavior | url=http://www.oreillynet.com/onlamp/blog/2006/08/roles_composable_units_of_obje.html | author=chromatic | year=2006}}</ref>
 
=== Regular expressions ===
{{main|Perl 6 rules}}
Perl's [[regular expression]] and string-processing support has always been one of its defining features.<ref>{{cite web | url=http://cslibrary.stanford.edu/108/EssentialPerl.html#re | title=Essential Perl: String Processing with Regular Expressions | author=Parlante, Nick | year=2000}}</ref> Since Perl's pattern-matching constructs have exceeded the capabilities of [[Formal language|formal]] regular expressions for some time, Perl 6 documentation will exclusively refer to them as ''regexes'', distancing the term from the formal definition.
 
Perl 6 provides a superset of Perl 5 features with respect to regexes, folding them into a larger framework called "rules" which provide the capabilities of [[context-sensitive]] [[parsing]] formalisms (such as the [[syntactic predicate]]s of [[parsing expression grammar]]s and [[ANTLR]]), as well as acting as a [[Closure (computer science)|closure]] with respect to their [[Scope (programming)|lexical scope]].<ref>{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S05.html | title=Synopsis 5: Regexes and Rules | author=Wall, Larry | date=[[2002-06-24]] }}</ref> Rules are introduced with the <code>rule</code> keyword which has a usage quite similar to subroutine definition. Anonymous rules can also be introduced with the <code>regex</code> (or <code>rx</code>) keyword, or they can simply be used inline as regexps were in Perl 5 via the <code>m</code> (matching) or <code>s</code> (search and replace) operators.
 
In ''Apocalypse 5'', Larry Wall enumerated 20 problems with "current regex culture". Among these were that Perl's regexes were "too compact and 'cute'", had "too much reliance on too few metacharacters", "little support for named captures", "little support for grammars", and "poor integration with [the] 'real' language".<ref>{{cite web | url=http://dev.perl.org/perl6/doc/design/apo/A05.html | title=Apocalypse 5: Pattern Matching | author=Wall, Larry | date=[[2002-06-04]] }}</ref>
 
=== Syntactic simplification ===<!-- This section is linked from [[Ellipsis]] -->
Some Perl 5 constructs have been changed in Perl 6, optimized for different syntactic cues for the most common cases. For example, the parentheses (round [[bracket]]s) required in [[control flow]] constructs in Perl 5 are now optional:<ref>{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S04.html | title=Synopsis 4: Blocks and Statements | author=Wall, Larry | date=[[2004-08-19]] }}</ref>
 
if is_true() {
for @array {
...
}
}
 
This is a trade-off, because the curly brace following the conditional must now have a space ahead of it, so it's merely a trade of one kind of marker (parens) for another kind of marker
(significant whitespace).
 
Also, the <code>,</code> (comma) operator is now a list constructor, so enclosing parentheses are no longer required around lists. The code
 
@array = 1, 2, 3, 4;
 
now makes @array an array with exactly the elements '1', '2', '3', and '4'.
 
=== Chained comparisons ===
Perl 6 allows comparisons to "chain". That is, a sequence of comparisons such as the following are allowed:
 
if C(20) <= $temperature <= C(25) { say "Room temperature!" }
 
This is treated as if each left-to-right comparison were performed on its own, and the result is logically combined via the <code>and</code> operation.
 
=== Lazy evaluation ===
Perl 6 uses the technique of [[lazy evaluation]] of lists that has been a feature of some [[functional programming]] languages such as [[Haskell (programming language)|Haskell]]:<ref name="syn9">{{cite web | url=http://dev.perl.org/perl6/doc/design/syn/S09.html | title=Synopsis 9: Data Structures | author=Wall, Larry | date=[[2004-09-13]] }}</ref>
 
@integers = 0..Inf; # integers from 0 to infinity
 
The code above will not crash by attempting to assign a list of infinite size to the array <code>@integers</code>, nor will it hang indefinitely in attempting to expand the list if a limited number of slots are searched.
 
This simplifies many common tasks in Perl 6 including input/output operations, list transformations and parameter passing.
 
=== Junctions ===
 
Perl 6 introduces the concept of ''junctions'': values that are composites of other values.<ref name="syn9"/> In the earliest days of Perl 6's design, these were called "superpositions", by analogy to the concept in [[quantum physics]] of [[quantum superposition]]s &mdash; waveforms that can simultaneously occupy several states until observation "collapses" them. A Perl 5 module released in [[2000]] by [[Damian Conway]] called <code>Quantum::Superpositions</code><ref>{{cite web | url=http://search.cpan.org/dist/Quantum-Superpositions/lib/Quantum/Superpositions.pm | title=Quantum::Superpositions - QM-like superpositions in Perl | author=[[Damian Conway|Conway, Damian]] | year=2002 }}</ref> provided an initial [[proof of concept]]. While at first, such superpositional values seemed like merely a programmatic curiosity, over time their utility and intuitiveness became widely recognized, and junctions now occupy a central place in Perl 6's design.
 
In their simplest form, junctions are created by combining a set of values with junctive [[Operator (programming)|operator]]s:
 
my $any_even_digit = 0|2|4|6|8; # any(0, 2, 4, 6, 8)
my $all_odd_digits = 1&3&5&7&9; # all(1, 3, 5, 7, 9)
 
<code>|</code> indicates a value which is equal to either its left ''or'' right-hand arguments. <code>&</code> indicates a value which is equal to both its left ''and'' right-hand arguments. These values can be used in any code that would use a normal value. Operations performed on a junction act on all members of the junction equally, and combine according to the junctive operator. So, <code>("apple"|"banana") ~ "s"</code> would yield <code>"apples"|"bananas"</code>. In comparisons, junctions return a single true or false result for the comparison. <code>|</code> or <code>any</code> junctions return true if the comparison is true for any one of the elements of the junction. <code>&</code> or <code>all</code> junctions return true if the comparison is true for all of the elements of the junction.
 
Junctions can also be used to more richly augment the type system by introducing a style of [[generic programming]] that is constrained to junctions of types:
 
sub get_tint ( RGB_Color|CMYK_Color $color, num $opacity) { ... }
sub store_record (Record&Storable $rec) { ... }
 
====Autothreading====
Junctions are unordered; <code>1|2|3</code> and <code>3|2|1</code> represent the same value. This lack of ordering means that the Perl 6 compiler can choose to evaluate junctive expressions ''in parallel''. For instance, the code:
 
for all(@array) { ... }
 
would indicate to the compiler that the <code>for</code> loop should be run in parallel, possibly in separate [[Thread (computer science)|threads]]. This feature is dubbed "autothreading"; its usage and implementation is not finalized and is a matter of debate in the development community.<ref>{{cite web | url=http://groups.google.com/group/perl.perl6.language/browse_frm/thread/868ab2f20deb00d8/9e7da05315e91e13?tvc=1#9e7da05315e91e13 | title=Junction Values | author=Adams, Rod | date=[[2005-02-15]] }}</ref>
 
===Macros===
In low-level languages, the concept of [[macro]]s has become synonymous with textual substitution of source-code due to the widespread use of the [[C preprocessor]]. However, high-level languages such as [[Lisp programming language|Lisp]] pre-dated C in their use of macros that were far more powerful.<ref>{{cite book | title=Successful Lisp: How to Understand and Use Common Lisp | author=Lamkins, David B. | date=[[2004-12-08]] | publisher=bookfix.com | url=http://psg.com/~dlamkins/sl/chapter20.html}}</ref> It is this Lisp-like macro concept that Perl 6 will take advantage of.<ref name="syn6"/> The power of this sort of macro stems from the fact that it operates on the program as a high-level [[data structure]], rather than as simple text, and has the full capabilities of the programming language at its disposal.
 
A Perl 6 macro definition will look like a subroutine or method definition, and can operate on unparsed strings, an [[Abstract syntax tree|AST]] representing pre-parsed code, or a combination of the two. A macro definition would look like this:
 
macro hello($what) {
q:code { say "Hello { {{{$what}}} }" };
}
 
In this particular example, the macro is no more complex than a C-style textual substitution, but because parsing of the macro parameter occurs before the macro operates on the calling code, diagnostic messages would be far more informative. However, because the body of a macro is executed at [[compile time]] each time it is used, many techniques of [[Optimization (computer science)|optimization]] can be employed. It is even possible to entirely eliminate complex computations from resulting programs by performing the work at compile-time.
 
== Hello world ==
The [[hello world program]] is often used in demonstrating a programming language's most routine usage. In Perl 6, hello world can be written:
 
say "Hello world"
 
-- though [[there is more than one way to do it]].The <code>say</code> function, which is new in Perl 6, prints its parameters (like the <code>print</code> function), but with a trailing [[newline]].
 
==References==
<references/>
 
== External links ==
===Specification===
* [http://dev.perl.org/perl6/doc/synopsis.html Synopses - The evolving summary of each Apocalypse, updated regularly]. These are considered to be the official language specification.
* [http://dev.perl.org/perl6/doc/exegesis.html Exegeses - Further explanation of each Apocalypse with code samples]
* [http://dev.perl.org/perl6/doc/apocalypse.html Apocalypses - The first-pass drafts from Larry Wall]
* [http://dev.perl.org/perl6/rfc The original community RFCs]
 
* [http://feather.perl6.nl/syn/ Official Perl 6 Documentation] These contain code snippets from the [[Pugs]] test suite.
 
===Implementations===
* [http://dev.perl.org/perl6/ The main site for Perl 6 development]
* [http://www.pugscode.org/ Pugs] - A current implementation of Perl 6, written in [[Haskell (programming language)|Haskell]].
* [http://search.cpan.org/dist/v6-alpha/ v6.pm] - A pure-perl implementation, based on a [http://pugs.blogs.com/pugs/2006/07/diagram_for_per.html Perl 6's CPAN stack].
* [http://www.parrotcode.org/ parrotcode] - The main site for [[Parrot virtual machine|Parrot]] development.
 
===Other===
* [http://planetsix.perl.org/ Planet Perl 6] - Perl 6's blogs aggregrator.
* [http://wiki.osdc.org.il/index.php/Larry_Wall_-_Present_Continuous%2C_Future_Perfect Present Continuous, Future Perfect] - Larry Wall's talk about Perl 5 and Perl 6 at Open Source Developer Conference 2006 in [[Netanya]], Israel (HTML, with links to slides and audio recording)
* [http://www.programmersheaven.com/2/Perl6-FAQ Perl 6 FAQ] - Answers a wide range of questions about Perl 6.
* [http://www.programmersheaven.com/2/Perl6-QuickStart Perl 6 Quick-Start] - A step-by-step guide to writing and running your first Perl 6 program.
 
[[Category:Perl]]
*Needham, Joseph (1986). ''Science and Civilization in China: Volume 4, Part 3''. Taipei: Caves Books, Ltd.
[[Category:Upcoming software]]
*Steinhardt, Nancy Shatzman (1997). ''Liao Architecture''. Honolulu: University of Hawaii Press.
 
[[cs:Perl 6]]
[[Category:Architectural history]]
[[es:Perl 6]]
[[Category:Chinese architecture]]
[[Categoryfr:SongPerl Dynasty6]]
[[fi:Perl 6]]
[[sv:Perl 6]]