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

吾有一計,可實現“\n,\t……” #128

Open
RyuGamer opened this issue Dec 18, 2019 · 18 comments
Open

吾有一計,可實現“\n,\t……” #128

RyuGamer opened this issue Dec 18, 2019 · 18 comments
Labels
syntax Suggestions to improve the syntax

Comments

@RyuGamer
Copy link

RyuGamer commented Dec 18, 2019

At present, there is no escape character in wenyan-lang.
I have an idea that we can use "符" as escape character.
\b → 退之符
\f → 頁之符
\n → 行之符
\t → 表之符

@nikacan
Copy link

nikacan commented Dec 18, 2019

錶 means watch, which is different from 表

@shyoshyo
Copy link

shyoshyo commented Dec 18, 2019

This could be integrated with the unicode notation for escape character mentioned in #84

Something like

吾有一言,曰「「問」」,萬國碼一萬二千三百之符,「「天地」」,萬國碼一萬二千三百零一之符,行之符,表之符,「「好在。」」。書之。

could be compiled to:

var a = "問" + "「" + "天地" + "」" + "\n" + "\t" + "好在。";
console.log(a);

which outputs:

問「天地」
	好在。

@melop
Copy link

melop commented Dec 18, 2019

然則冗長,頓失文言之利也。況若人欲言“表之符”三字,何以書之?
何不以“\表” "\行" “\退” 記之?若嫌“"為西洋符號,亦可擇生僻字代之。
吾亦感數字以漢文書之實為繁瑣,誠遜於阿拉伯數字也。望有方案。

@shyoshyo
Copy link

shyoshyo commented Dec 18, 2019

況若人欲言“表之符”三字,何以書之?

In the case 表之符 should be outputted, one could write:

  吾有一言,曰「「表之符」」。書之。

In the case \t should be outputted, writing:

  吾有一言,曰表之符。書之。

instead is a possible solution.

@kotritrona
Copy link

看官,切勿因噎废食也。倘若人欲言表之符三字,则直言表之符,并于一句之后增“之字”以说明,去其二义性便可。

@shyoshyo
Copy link

shyoshyo commented Dec 18, 2019

看官,切勿因噎废食也。倘若人欲言表之符三字,则直言表之符,并于一句之后增“之字”以说明,去其二义性便可。

This also makes sense. Letting

「「表之符」」之字

mean something equivalent to raw string in python:

r'\t'

is also a possible solution.

@melop
Copy link

melop commented Dec 18, 2019

看官,切勿因噎废食也。倘若人欲言表之符三字,则直言表之符,并于一句之后增“之字”以说明,去其二义性便可。

然則如欲言“表之符之字”五字,則當何如?吾思之甚繁。

@Xander-C
Copy link

则以「「表之符之字」之字」表「表之符之字」
以「「表之符」之字」表「表之符」
而「表之符」则为西洋语之\t
I am poor at Classical Chinese.

@rynkis
Copy link

rynkis commented Dec 19, 2019

通假可解之。

例一:

吾有一言,曰「「問上天地下行表好在。」」。上通「。下通」。假行作換行。假表為表格。書之。

could be compiled to:

console.log('問「天地」\n\t好在。')

directly,
or compile to:

let a = '問上天地下行表好在。'
  .replace(//g, '「')
  .replace(//g, '」')
  .replace(//g, '\n')
  .replace(//g, '\t')
console.log(a)

with detail.

例二:

吾有一言,曰「「辭云:行前路曼曼其脩遠兮,行空吾將上下而求索。後」」。前通「。後通」。假行為換行。假空作空格。書之。
console.log('辭云:\n「路曼曼其脩遠兮,\n 吾將上下而求索。」')

or

let a = '辭云:行前路曼曼其脩遠兮,行空吾將上下而求索。後'
  .replace(//g, '「')
  .replace(//g, '」')
  .replace(//g, '\n')
  .replace(//g, ' ')
console.log(a)

@melop
Copy link

melop commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

@shyoshyo
Copy link

shyoshyo commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

just replace “上”“下”“表” with any char not shown in the sentence, as 吾將上下而求索 & 前後 in the 2nd aforementioned example.

@melop
Copy link

melop commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

just replace “上”“下”“表” with any char not shown in the sentence, as 吾將上下而求索 & 前後 in the 2nd aforementioned example.

My point was that the proposal doesn't offer a general, elegant solution - one has to inspect the string before deciding on the escape characters. The escape characters may need adjustment if the string is changed. The solution is also far from elegant, generating a long trail of verbose sentences just to deal with escaping, let alone the inefficient speed with multiple replace() functions when translated into javascript. The escaping process should be dealt with at the compiler stage.

I feel that instead of reinventing the wheel, a better solution is just to follow what other language designers have done. Stick with one rarely used character as a prefix. In c-like languages this would be "\". Perhaps one can pick another rarely used Chinese character for the purpose of escaping.

@rynkis
Copy link

rynkis commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

just replace “上”“下”“表” with any char not shown in the sentence, as 吾將上下而求索 & 前後 in the 2nd aforementioned example.

My point was that the proposal doesn't offer a general, elegant solution - one has to inspect the string before deciding on the escape characters. The escape characters may need adjustment if the string is changed. The solution is also far from elegant, generating a long trail of verbose sentences just to deal with escaping, let alone the inefficient speed with multiple replace() functions when translated into javascript. The escaping process should be dealt with at the compiler stage.

I feel that instead of reinventing the wheel, a better solution is just to follow what other language designers have done. Stick with one rarely used character as a prefix. In c-like languages this would be "". Perhaps one can pick another rarely used Chinese character for the purpose of escaping.

You are right, and you can use the char which is 避諱 or 河蟹.

秦漢以降,再無雅言。皆為「帶著鐐銬跳舞」。
Since Qin and Han dynasties, there are no more elegant words. All are "dancing with shackles."

@melop
Copy link

melop commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

just replace “上”“下”“表” with any char not shown in the sentence, as 吾將上下而求索 & 前後 in the 2nd aforementioned example.

My point was that the proposal doesn't offer a general, elegant solution - one has to inspect the string before deciding on the escape characters. The escape characters may need adjustment if the string is changed. The solution is also far from elegant, generating a long trail of verbose sentences just to deal with escaping, let alone the inefficient speed with multiple replace() functions when translated into javascript. The escaping process should be dealt with at the compiler stage.
I feel that instead of reinventing the wheel, a better solution is just to follow what other language designers have done. Stick with one rarely used character as a prefix. In c-like languages this would be "". Perhaps one can pick another rarely used Chinese character for the purpose of escaping.

You are right, and you can use the char which is 避諱 or 河蟹.

秦漢以降,再無雅言。皆為「帶著鐐銬跳舞」。
Since Qin and Han dynasties, there are no more elegant words. All are "dancing with shackles."

Good idea, perhaps 諱 would be a good enough option since it is rarely used enough. So something like 「「甲諱表乙諱表丙諱表諱行」」= "甲\t乙\t丙\t\n"

@rynkis
Copy link

rynkis commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

just replace “上”“下”“表” with any char not shown in the sentence, as 吾將上下而求索 & 前後 in the 2nd aforementioned example.

My point was that the proposal doesn't offer a general, elegant solution - one has to inspect the string before deciding on the escape characters. The escape characters may need adjustment if the string is changed. The solution is also far from elegant, generating a long trail of verbose sentences just to deal with escaping, let alone the inefficient speed with multiple replace() functions when translated into javascript. The escaping process should be dealt with at the compiler stage.
I feel that instead of reinventing the wheel, a better solution is just to follow what other language designers have done. Stick with one rarely used character as a prefix. In c-like languages this would be "". Perhaps one can pick another rarely used Chinese character for the purpose of escaping.

You are right, and you can use the char which is 避諱 or 河蟹.
秦漢以降,再無雅言。皆為「帶著鐐銬跳舞」。
Since Qin and Han dynasties, there are no more elegant words. All are "dancing with shackles."

Good idea, perhaps 諱 would be a good enough option since it is rarely used enough. So something like 「「甲諱表乙諱表丙諱表諱行」」= "甲\t乙\t丙\t\n"

yes, it's so ironic

@xubaiw
Copy link

xubaiw commented Dec 19, 2019

然則言中另存“上”“下”“表”之語又當何如?

just replace “上”“下”“表” with any char not shown in the sentence, as 吾將上下而求索 & 前後 in the 2nd aforementioned example.

My point was that the proposal doesn't offer a general, elegant solution - one has to inspect the string before deciding on the escape characters. The escape characters may need adjustment if the string is changed. The solution is also far from elegant, generating a long trail of verbose sentences just to deal with escaping, let alone the inefficient speed with multiple replace() functions when translated into javascript. The escaping process should be dealt with at the compiler stage.
I feel that instead of reinventing the wheel, a better solution is just to follow what other language designers have done. Stick with one rarely used character as a prefix. In c-like languages this would be "". Perhaps one can pick another rarely used Chinese character for the purpose of escaping.

You are right, and you can use the char which is 避諱 or 河蟹.
秦漢以降,再無雅言。皆為「帶著鐐銬跳舞」。
Since Qin and Han dynasties, there are no more elegant words. All are "dancing with shackles."

Good idea, perhaps 諱 would be a good enough option since it is rarely used enough. So something like 「「甲諱表乙諱表丙諱表諱行」」= "甲\t乙\t丙\t\n"

但是如此會讓語意難以理解。

@rynkis
Copy link

rynkis commented Dec 19, 2019

但是如此會讓語意難以理解。

只是選字而已,通假說明還是需要的,因為每一個時代的避諱字不一樣,we won't rebuild complier for every dynasty.

「香菱度名諱表曰石頭記」

@LingDong- LingDong- added the syntax Suggestions to improve the syntax label Dec 24, 2019
@AiDSl
Copy link

AiDSl commented Dec 31, 2019

如果兼用兩個字符 語與諱呢
採取貪婪法
語諱輸出諱
諱語輸出語
語可以加字符當作格式符號
例如
語畢\n 語末\0
語出\r 語畏\0 語進\t
如果語或諱抓到unexpected char
那麼輸出該char
舉例
吾有一言,曰『『言諱語乃交互之根本語進不語諱言亦有所增益語畢語出解為語畢語出語進一語進二語畢語出語進三語進四語畢語出語末』』書之。
預期輸出
『『
言語乃交互之根本 不諱言亦有所增益
解為
一 二
三 四
』』

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

No branches or pull requests

10 participants