Rock It 《ML》JupyterLab 【丁】Code《七》語義【六】解讀‧四‧Redex 三‧中

古人說︰熟讀唐詩三百首,不會作詩也會吟。就像能寫小說的少,會讀小說的多。鏡花緣演繹『熟能生巧』,自有其理也。

鏡花緣/第031回

話說林之洋向通使道:“老兄果真舍得令愛教俺妹夫帶去,俺們就替你帶去,把病治好,順便帶來還你。”蘭音向通使垂淚道:“父親說那裏話來!母親既已去世,父親跟前別無兒女,女兒何能拋撇遠去 ?今雖抱病,不能侍奉,但父女能得團聚,心是安的,豈可一旦分為兩處!”通使道:“話雖如此,吾兒之病,若不投 奔他邦,以身就藥,何能脫體?現在病勢已到九分,若再耽捆,一經不起,教為父的何以為情?少不得也是一死!此時父女遠別,雖是下策,吾女倘能病好,便中寄我一信,為父自然心安。以此看來:遠別一層,不但不是下策,竟可保全我們兩命。況天朝為萬邦之首,各國至彼朝覲的甚多,安知日後不可搭了鄰邦船只來看我 哩。你今遠去,雖不能在家侍奉,從此我能多活幾年,也就是你仰體盡孝之處。現在承繼有人,宗祧一事,亦已無虞。你在船上,又有大賢令甥女作伴,我更放心。 為父主意已定,吾兒依我,方為孝女。不必猶疑,就拜大賢為父。此去天朝,倘能病痊,將來自有好處。”即攜蘭音向唐敖叩拜,認為義父,並拜多、林及呂氏諸 人。通使也與唐敖行劄,再再諄托。唐敖還禮道:“尊駕以兒女大事見委,小弟敢不盡心!誠忍效勞不周,有負所托,甚為惶恐!此去惟有將令愛之恙上緊療治。第 我等日後回鄉,能否繞路再到貴處,不能預定。至令愛姻事,亦惟盡心酌辦,以報知己,幸無掛懷!”只見通使僕人取了銀子送來。通使道:“這是白銀一千,內有五百,乃小弟微敬,其餘五百,為小女藥餌及婚嫁之費。至於衣服首飾,小弟均已備辦,不須大賢費心 。”眾僕人抬了八只皮箱上來。唐敖道:“令愛衣飾各物既已 預備,自應令其帶去;所賜之銀,斷不敢領。至姻嫁之費,亦何須如此之多,仍請尊駕帶回,小弟才能應命。”通使道:“小子跟前別無兒女 ,留此無用。況家有薄 田,足可度日。望大賢帶去,小子才能心安 。”多九公道:“通使大人多贈銀兩,無非愛女之意,唐兄莫若權且收下,將來俟小姐婚嫁,盡其所有,多辦妝奩送去, 豈不更妙?”唐敖連連點頭,即命來人將銀裝入箱內,抬進後艙。父女灑淚而別。蘭音從此呼呂氏為舅母,呼婉如為表姐;帶著乳母,就與婉如一同居住。

眾人收拾開船。多九公要到後面看舵,唐敖道:“九公那位高徒向來看舵甚好,何必自去?難道不看字母麼?”多九公笑道:“我倒忘了 。”唐敖取出字母,只見上面寫著:

昌○○○○○○○○○○○○○○○○○○○○○
茫○○○○○○○○○○○○○○○○○○○○○
秧○○○○○○○○○○○○○○○○○○○○○
秧梯○○○○○○○○○○○○○○○○○○○○○
羌○○○○○○○○○○○○○○○○○○○○○
商○○○○○○○○○○○○○○○○○○○○○
槍○○○○○○○○○○○○○○○○○○○○○
良○○○○○○○○○○○○○○○○○○○○○
囊○○○○○○○○○○○○○○○○○○○○○
杭○○○○○○○○○○○○○○○○○○○○○
秧批○○○○○○○○○○○○○○○○○○○○○
方○○○○○○○○○○○○○○○○○○○○○
秧低○○○○○○○○○○○○○○○○○○○○○
薑○○○○○○○○○○○○○○○○○○○○○
秧妙○○○○○○○○○○○○○○○○○○○○○
桑○○○○○○○○○○○○○○○○○○○○○
郎○○○○○○○○○○○○○○○○○○○○○
康○○○○○○○○○○○○○○○○○○○○○
倉○○○○○○○○○○○○○○○○○○○○○
昂○○○○○○○○○○○○○○○○○○○○○
娘○○○○○○○○○○○○○○○○○○○○○
滂○○○○○○○○○○○○○○○○○○○○○
香○○○○○○○○○○○○○○○○○○○○○
當○○○○○○○○○○○○○○○○○○○○○
將○○○○○○○○○○○○○○○○○○○○○
湯○○○○○○○○○○○○○○○○○○○○○
瓤○○○○○○○○○○○○○○○○○○○○○
秧兵○○○○○○○○○○○○○○○○○○○○○
幫○○○○○○○○○○○○○○○○○○○○○
岡○○○○○○○○○○○○○○○○○○○○○
臧○○○○○○○○○○○○○○○○○○○○○
張張張珠珠張珠珠珠珠珠張真中珠招齋知遮詁氈專
鷗婀鴉逶均鶯帆窩窪歪汪廂○○○○○○○○○○○○○○○○○○○○○

三人翻來複去,看了多時,絲毫不懂。林之洋道:“他這許多圈兒,含著什麼機關?大約他怕俺們學會,故意弄這迷團騙俺們的!”唐敖道:“他為一國之主,豈有騙人之理?據小弟看來:他這張、真、中 、珠……十一字,內中必藏奧妙。他若有心騙人,何不寫許多難字 ,為何單寫這十一字?其中必有道理!”多九公 道:“我們何不問問枝小姐?他生長本國,必是知音的。”林之洋把婉如、蘭音喚出,細細詢問。誰知蘭音因自幼多病,雖讀過見年書,並未學過音韻。三人聽了, 不覺興致索然,只得暫且擱起。

……

次日,三人又聚一處,講來講去,仍是不懂。多九公道:“枝小姐既不曉得音韻,我想婉如侄女他最心靈,或者教他幾遍,她能領略,也未可知。”林之洋將 婉如喚出,蘭音也隨出來,唐敖把這緣故說了 ,婉如也把“張真中珠”讀了兩遍,拿著那張字母同蘭音看了多時。蘭音猛然說道:“寄父請看上面第六行‘商’字, 若照‘張真中珠’一例讀去,豈非‘商申樁書’麼?”唐、多二人聽了,茫然不解。林之洋點頭道:“這句‘商申樁書’,俺細聽去,狠有意味。甥女為甚道恁四 字?莫非曾見韻書麼?”蘭音道:“甥女何嘗見過韻書。想是連日聽舅舅時常讀他,把耳聽滑了,不因不由說出這四字。其實甥女也不知此句從何而來。”多九公 道:“請教小姐:若照‘張夏中珠’,那個‘香’字怎樣讀?”蘭音正要回答。林之洋道:“據俺看來:是‘香欣胸虛’。”蘭音道:“舅舅說的是。”唐敖道:“ 九公不必談了。俗語說的:‘熟能生巧。’舅兄昨日讀了一夜,不但他已嚼出此中意味,並且連寄女也都聽會,所以隨問隨答,毫不費事。我們別無良法,惟有再去 狠讀,自然也就會了。”多九公連連點頭。二人複又讀了多時,唐敖不覺點頭道:“此時我也有點意思了。”林之洋道:“妹夫果真領會?俺考你一考:若照‘張真 中珠’,‘岡’字怎讀?”唐敖道:“自然是‘岡根公孤’了 。”林之洋道:“‘秧’字呢?”婉如接著道:“‘秧因雍淤’。”多九公聽了,只管望著發愣。想了 多時,忽然冷笑道:“老夫曉得了:你們在歧舌國不知怎樣騙了一部韻書,夜間暗暗讀熟,此時卻來作弄老夫。這如何使得了快些取出給我看看!”林之洋道:“俺 們何曾見過什麼韻書。如欺九公,教俺日後遇見黑女,也象你們那樣受罪。”多九公道 :“既無韻書,為何你們說的,老夫都不懂呢?”唐敖道:“其實並無韻書, 焉敢欺瞞。此時縱讓分辯,九公也不肯信;若教小弟講他所以然之故,卻又講不出。九公惟有將這‘張真中珠’再讀半日,把舌尖練熟,得了此中意味,那時才知我 們並非作弄哩。”多九公沒法,只得高聲朗誦,又讀起來。讀了多時,忽聽婉如問道:“請問姑夫:若照‘張真中珠’,不知‘方’字怎樣讀?”唐敖道:“若論‘ 方’字……”話未說完,多九公接著道:“自然是‘方分風夫’了。”唐敖拍手笑道:“如今九公可明白了。這‘方分風夫’四字,難道九公也從什麼韻書看出 麼?”多九公不覺點頭道:“原來讀熟卻有這些好處。”大家彼此又問幾句 ,都是對答如流。林之洋道:“俺們只讀得張、真、中、珠……十一字,怎麼忽然生出許 多文法?這是什麼緣故?”唐敖道:“據小弟看來:即如五聲‘通、同、桶、痛、禿’之類,只要略明大義,其餘即可類推。今日大家糊裏糊塗把字母學會,已算奇了;寄女同侄女並不習學,竟能聽會,可謂奇而又奇。而且習學之人還未學會,旁聽之人倒先聽會,若不虧寄女道破迷團,只怕我們還要亂猜哩。但張、真、中、 珠……十一字之下還有許多小字,不知是何機關?”

 

─── 《L4K ︰ 通往 PYTHON 的道路 ── RUR-PLE 斟酌

 

祇為一時手癢,好奇 MarioLANG 如何『打招呼』呢?

Good sample programs

Is anyone willing to make any of the classic program examples in this language, like Hello World, Cat Programs, or working 99 Bottles programs? —JWinslow23 (talk) 18:23, 21 September 2013 (UTC)

I created a Hello World program (hoping MarioLANG won’t crash when faced with $s and letter characters).

               MarioLANG Hello World    <
         = =============================^<
           |   Created by JWinslow23   |=^<
         = ==============================="=
++++++++++
========== =
          >)+++++++)++++++++++)+++)+((((-[!)++.)+.
         =================================#======= =
  .------.+++.).+++++++++++++++((.++).+++..+++++++<
= ==================================================
 >--------.)+.).
================ =        |*
                         

    \[$\]

    \[$\]

    \[>\]

=========== ======

Anyone have any others? —JWinslow23 (talk) 19:31, 21 September 2013 (UTC)

I suspect the letters will work fine as the spec says unknown characters are comments. I am more uncertain about your castle made of elevators. 😛

However, the original author never fleshed out everything exactly, and hasn’t been seen in 3 years. His website is dead (and not on Wayback) and I don’t remember him making any interpreter, so in my opinion whoever actually makes one gets to decide the missing details. —Ørjan (talk) 23:42, 21 September 2013 (UTC)

Oerjan, I didn’t mean to make the castle out of elevators. I’ll change it to s. --<a style="color: #808080;" title="User:JWinslow23" href="https://esolangs.org/wiki/User:JWinslow23">JWinslow23</a> (<a class="new" style="color: #808080;" title="User talk:JWinslow23 (page does not exist)" href="https://esolangs.org/w/index.php?title=User_talk:JWinslow23&action=edit&redlink=1">talk</a>) 00:25, 22 September 2013 (UTC)</span>  <span style="color: #808080;">Also, I think there should really be a Mario starting point command. It could be unclear. Anyone who makes the interpreter, either specify a character to use, or make you specify it with input. --<a style="color: #808080;" title="User:JWinslow23" href="https://esolangs.org/wiki/User:JWinslow23">JWinslow23</a> (<a class="new" style="color: #808080;" title="User talk:JWinslow23 (page does not exist)" href="https://esolangs.org/w/index.php?title=User_talk:JWinslow23&action=edit&redlink=1">talk</a>) 03:57, 22 September 2013 (UTC)</span>  <span style="color: #808080;">Well, the other example programs seem to just start in something like the upper left corner/first character in file, and are written so that all the obvious interpretations of this are unambiguous. Your "Hello, World" on the other hand would have different effects dependent on interpretation, here are some I could think of:</span> <ul>  	<li><span style="color: #808080;">First character of file would make Mario fall down onto the row of <code>+</code>'s, which probably doesn't give the right result.</span></li>  	<li><span style="color: #808080;">First non-comment character means the <code><</code> on the first line, and would probably work.</span></li>  	<li><span style="color: #808080;">First character where Mario doesn't immediately fall would be above the first <code>=</code> on the second line. Happens to work because the <code>></code> below gets him to move in the right direction either way.</span></li> </ul> <span style="color: #808080;">None of these interpretations makes Mario go toward the right across the top text, which somehow seems to me like what was intended. Actually, making Mario start on the first <i>non-space</i> character would work for that, but means comments matter for the starting point.</span>  <span style="color: #808080;">And of course none of these interpretations work if you want to have stuff above the starting point for esthetic reasons. And I seem to recall that in Donkey Kong games Mario often starts at the bottom, not the top...</span>  <span style="color: #808080;">On the other hand I don't think it is appropriate for people other than the original author to add things to the language spec that are inconsistent with what's already there, including the examples. --<a style="color: #808080;" title="User:Oerjan" href="https://esolangs.org/wiki/User:Oerjan">Ørjan</a> (<a style="color: #808080;" title="User talk:Oerjan" href="https://esolangs.org/wiki/User_talk:Oerjan">talk</a>) 13:10, 22 September 2013 (UTC)</span>  <span style="color: #808080;">Oerjan, there are two problems with your theory.</span>  <span style="color: #808080;">1. The first character is actually what I intended (this is my MarioLANG interpretation of the brainfuck Hello World example on this wiki), provided Mario automatically moves right when he hits ground and no directions are already specified. Apparently, the example in the article (and what I could make out of the 99 Bottles program) shows that that is how it would work out.</span>  <span style="color: #808080;">2. It will work. Mario goes in the loop after adding 10 to cell 0. Then you drop into the While loop, doing what is specified in the loop. Then, if cell 0 is not equal to 0, it stops moving after it gets on the elevator. If cell 0 is equal to 0, however, it ignores the <code>!</code> and keeps moving after it triggered the elevator. Then it goes through the rest of the program, and then walks into my "castle" made out of dollar bill signs. It is a non-command, so Mario ignores these symbols. Then it falls through a hole in the ground, ending the program. --<a style="color: #808080;" title="User:JWinslow23" href="https://esolangs.org/wiki/User:JWinslow23">JWinslow23</a> (<a class="new" style="color: #808080;" title="User talk:JWinslow23 (page does not exist)" href="https://esolangs.org/w/index.php?title=User_talk:JWinslow23&action=edit&redlink=1">talk</a>) 15:11, 22 September 2013 (UTC)</span> <dl>  	<dd><span style="color: #808080;">Oh, OK. I guess I should have actually read the program before assuming. :) --<a style="color: #808080;" title="User:Oerjan" href="https://esolangs.org/wiki/User:Oerjan">Ørjan</a> (<a style="color: #808080;" title="User talk:Oerjan" href="https://esolangs.org/wiki/User_talk:Oerjan">talk</a>) 01:32, 23 September 2013 (UTC)</span></dd> </dl> <span style="color: #808080;">Cat program: (On the first input, input 0 for ASCII input and 1 for numeric input) (Assumes Mario starts in the top-left corner)</span> <pre class="lang:default decode:true">       <   <   =====" ==" ;>[;[:[!>,.! =======#===#</pre> <img class="alignnone size-full wp-image-97193" src="http://www.freesandal.org/wp-content/uploads/Mario-DrRacket-(在-rock64)_3.png" alt="" width="602" height="641" />     <span style="color: #666699;">既已找到;熟讀多遍、一一練習,終能跌撞寫了個『倒數計時』之程式︰</span>  <img class="alignnone size-full wp-image-97234" src="http://www.freesandal.org/wp-content/uploads/Mario-DrRacket-(在-rock64)_5.png" alt="" width="602" height="611" />     <span style="color: #666699;">也算勉強擠身此門中☻</span>  <span style="color: #666699;">卻不了<a style="color: #666699;" href="https://github.com/mlang/mario">那個作者為何</a>取消跳躍</span>  <img class="alignnone size-full wp-image-97215" src="http://www.freesandal.org/wp-content/uploads/Mario-DrRacket-(在-rock64)_4.png" alt="" width="602" height="641" />     <span style="color: #666699;">動作哩!</span> <pre class="lang:default decode:true">rock64@rock64:~/mario more semantics.rkt
#lang racket

(provide (all-defined-out))

(struct env (memory heading skip?) #:mutable #:transparent)
(struct mem (byte previous next) #:mutable)
(struct cell (char [left #:mutable] [up #:mutable] [right #:mutable] [down #:mutable])
#:prefab)

(define (new-env)
(env (mem 0 #f #f) ‘right #f))

(define (decrease-pointer env)
(let ([pos (env-memory env)])
(when (eq? (mem-previous pos) #f)
(set-mem-previous! pos (mem 0 #f pos)))
(set-env-memory! env (mem-previous pos))
env))

(define (increase-pointer env)
(let ([pos (env-memory env)])
(when (eq? (mem-next pos) #f)
(set-mem-next! pos (mem 0 pos #f)))
(set-env-memory! env (mem-next pos))
env))

(define (update-byte! env func)
(let ([memory (env-memory env)])
(set-mem-byte! memory (func (mem-byte memory)))))

(define (exec-instruction cell env)
(if (env-skip? env)
(set-env-skip?! env #f)
(case (cell-char cell)
[(#\+) (update-byte! env add1)]
[(#\-) (update-byte! env sub1)]
[(#) (decrease-pointer env)]      [(#) (increase-pointer env)]
[(#\.) (write-byte (mem-byte (env-memory env))) (flush-output)]
[(#\:) (write-string (format “~a” (mem-byte (env-memory env))) (current-output-por
t))]
[(#\,) (set-mem-byte! (env-memory env) (read-byte (current-input-port)))]
[(#\;) (set-mem-byte! (env-memory env) (read (current-input-port)))]
[(#\>) (set-env-heading! env ‘right)]
[(#\<) (set-env-heading! env ‘left)]
[(#\@) (set-env-heading! env (case (env-heading env)
[(right) ‘left] [(left) ‘right]
[else (env-heading env)]))]
[(#\!) (set-env-heading! env #f)]
[(#\[) (when (= (mem-byte (env-memory env)) 0)
(set-env-skip?! env #t))])))

 

莫非這樣仍巧得

Turing-complete

A programming language is said to be Turing-complete if it is in the same computational class as a Turing machine; that is to say, that it can perform any calculation that a universal Turing machine can. This is considered significant because, under the Church-Turing thesis, a Turing machine is the embodiment of the intuitive notion of an algorithm.

Relationship to computation

One of the more common misconceptions about Turing-completeness is that it is something that is required to perform any sort of computations (and that, conversely, any system that can perform some computations is Turing-complete.)

This is not the case when talking about a restricted set of computations. A finite-state automaton, for example, can be constructed which computes the Ackermann function f(m, n) for 1 < m < 1000 and 1 < n < 1000. In fact, such an evaluation could be stored in a million-cell lookup table.

This issue is further explored in the next section.

Relationship to the physical world

Turing-completeness applies to abstract systems (such as languages and formal automata) but not to real ones (such as computers and interpreters.) Physical machines have the following properties:

  • they do not have unbounded storage space; and
  • they eventually break down.

For these reasons, it should be obvious that no actual computer can be Turing-complete. However, it is also obvious that physical computers are perfectly capable of performing practical, finite computations in spite of that.

By extension, implementations of languages (compilers and interpreters) on physical computers are also not Turing-complete, but are nonetheless capable of specifying computations.

Therefore, it can be useful to make a distinction between being “usable for computation” and being Turing-complete. A language can be “usable for computation” while not being Turing-complete; all Turing-complete systems are “usable for computation”, however.

SMETANA is “usable for computation”, in that it is limited only by the code size of the program one chooses to write. Arguments have been made that Malbolge is also “usable for computation.”

A formal definition of “usable for computation” is currently being sought.

Overspecification

Often, a programming language is “after the fact” in that its specification comes from an attempt to describe the behavior of an implementation of that language.

As has just been noted, such implementations, being based as they are on physical machines, cannot be Turing-complete. So when this is done, there is a danger that the language will be overspecified, and that limitations of the physical machine will be reflected in the description of the language. This, often needlessly, causes the language to fail to be Turing-complete.

An interesting example of this is the C programming language. The C specification requires an integer result from sizeof() operator. The sizeof() operator’s result is an unsigned integer, of type size_t, for ANSI C, or an int or long for traditional C. The range of these integers is bounded. Since the sizeof() any object in a C implementation must be a finite size, then C cannot be Turing-complete, because it cannot address an unbounded storage space.

There are sometimes ways out of this. If a language specification requires that the size of some address (for example) be “implementation-dependent but no less than 16 bits” then one can argue that there exists an “implementation” where the size of addresses is unbounded, and that this “implementation” is Turing-complete. (That is, provided that the concept of an “implementation” which can never be implemented on a real computer is unproblematic.)

………

 

『歸結』耶?