Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

08 方術第八中若干问题反馈 #19

Open
wglnngt opened this issue Jul 27, 2020 · 3 comments
Open

08 方術第八中若干问题反馈 #19

wglnngt opened this issue Jul 27, 2020 · 3 comments

Comments

@wglnngt
Copy link

wglnngt commented Jul 27, 2020

其一:函數定義中的傳参命名,『名之曰』則不可編譯通過,『曰』可正常編譯。
如:
吾有一術。名之曰「論戰」。欲行是術。必先得一言。名之曰「恃」。乃行是術曰。則編譯出錯。
吾有一術。名之曰「論戰」。欲行是術。必先得一言。曰「恃」。乃行是術曰。則正常運行。

其二:循環體與判斷語句重疊時,易產生多收尾或少收尾現象。

如:

恆為是。
若「藏」之長大於「層」者。乃止也。
吾有一列。充「藏」以其也。
注曰。『其它正常循環體中邏輯語句』
云云。

編譯正常,但邏輯異常。

恆為是。
若「藏」之長大於「層」者。乃止也。
吾有一列。充「藏」以其矣。
注曰。『其它正常循環體中邏輯語句』
云云。

則一切正常。
特別是循環體中包含『若非……也』、『若非……云云』的語句,更容易出錯(漏寫或多寫也/云云)。

其三:『篩剔』例中調用例子函數名誤寫爲『濾』。

@LingDong-
Copy link
Member

LingDong- commented Jul 27, 2020

Hi @wglnngt ,

Thanks a lot for pointing out the issues.

其一

名之 in function parameters are indeed typos, 曰「恃」 is the correct syntax, I've corrected them now: 77581d4

其二

Indeed the first snippet has syntax errors and the second one is syntactically correct. I think the compiler does a correct job of finding the error. e.g. running the first snippet on https://ide.wy-lang.org/ gives:

SyntaxError: Unexpected token '}'

And javascript:

while (true) {
  if (.length > ) {
    break;
  };
  var _ans1 = [];
  .push(_ans1);
}; /*"其它正常循環體中邏輯語句"*/
};

Which seems like the correct behavior.

Assuming that you took the snippets out of 賈憲三角 example, I think the confusion might come from the fact that the indentation are garbled due to space/tab issue (now fixed), and that I'm merging some lines to make it read more smoothly and more succint.

The actual structure is like so:

恆為是。
	若「藏」之長大於「層」者。
		乃止
	也
	吾有一列。充「藏」以其。
也。

⋯⋯

若「知甲」者。
	⋯⋯
若非。
	⋯⋯
云云。

⋯⋯

So the first part is actually a while(true){if(case)break; statement} logic, which one might write as while(!case){statement} in other languages.

其三

Oops, typo. Now corrected in d6761e2

Thanks again for spotting these mistakes!

@wglnngt
Copy link
Author

wglnngt commented Jul 28, 2020

感謝回覆與處理。例二反饋確引用不當,感謝指正。

關于例程代碼的簡寫。個人建議可以先按邏輯語法當斷則斷。易于新學者更快理解用法(新學者往往還未建立足夠的關鍵語法敏感度,且之乎者也云云之類,初學之時易就以往漢語語境經驗一眼帶過)。如:

凡「甲」中之「元」。
	施「法」於「元」。
	若其然者。
		充「乙」以「元」。
	也。
云云。

此義一目了然。后跟以簡潔版。

凡「甲」中之「元」。
	施「法」於「元」。若其然者。充「乙」以「元」也。
云云。

如此,既可明語法之要點,亦可免因疏忽導致的語法問題(上述代碼在最近更新b19072e中,仍少一結束關鍵字云云/也),后加以簡明版代碼,兩相比較,更可彰顯漢語代碼結構之美。:)

@LingDong-
Copy link
Member

Thanks a lot @wglnngt ,

I just fixed the missing 云云 mistake: 538a000

My original plan was to use more verbosely formatted examples in the early chapters, and assume by chapter 8 the reader is familiar enough with most wenyan syntaxes that they'll be able to read the condensed ones. I also want to avoid repeating examples twice just for showing whitespace differences. But your suggestion does make a lot of sense too, let me think more about this.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants