Wenyan: 想到一种switch语句的实现

Created on 18 Dec 2019  ·  6Comments  ·  Source: wenyan-lang/wenyan

简单地来自最熟悉的论语😂

吾日省「吾身」:
    其「七十七」乎?
            代码块一。
            乃止。
    其「六十六」乎?
            代码块二。
            乃止。
    若非也:
            代码块三。

临时起意想到的,还可以改一下,比如:

  1. “日省”可以改为“省”,因为加了“日”就有了一种是在循环之中的次序的感觉
  2. 因为case后面加的都是值,所以原文中没有“其”,我给加上了,感觉通顺一点
  3. 最后那个default翻译成“若非也”好像不是很妥当,但是我一时也想不到更好的了,见谅😂
syntax

Most helpful comment

Nice! Thanks! I like the idea. Will consider adding it to the syntax. Perhaps 竟皆非乎 for default? :-P

All 6 comments

Nice! Thanks! I like the idea. Will consider adding it to the syntax. Perhaps 竟皆非乎 for default? :-P

想到一个弗向者乎 for default
竟皆非乎其实也不错,但是感觉“竟”带了一点情感hhh,用在这里好像有点怪怪的😂😂
另外看到其他issue里有说《九章算术》的,可以统一一下格式,把首句改为:
今有「吾身」者:
或者:
吾有「吾身」者:

You're right. But I'm using in the sense of "in the end" not as in "unexpectedly".
Also, please see https://github.com/LingDong-/wenyan-lang/pull/35
It turns out

“弗”是“不之”的合音字,後面要跟及物動詞

I learned that today. ;) So probably it needs to be
非向者乎
OR
向者皆不是乎

Thanks again for your suggestions!

个人认为就不要加上 break 了避免太过冗长,参考下 Swift 的 fallthrough

省「吾身」:
其「一」:
述一。
其「二」:
述二。
逋欠:
补缺。

其一
其二
其余 // for default
如何?

另赞同干掉 break

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zxch3n picture zxch3n  ·  5Comments

yejingchen picture yejingchen  ·  6Comments

Tim1995 picture Tim1995  ·  4Comments

nobodxbodon picture nobodxbodon  ·  3Comments

calpa picture calpa  ·  5Comments